[mod_python] Can i have both Marshal and Signed CookieswithPublisher?

Clodoaldo Pinto Neto clodoaldo.pinto at gmail.com
Tue Oct 31 08:49:26 EST 2006


2006/10/31, Clodoaldo Pinto Neto <clodoaldo.pinto at gmail.com>:
> >     def parse(Class, s, secret, downgrade=False, strict=False):
>
> Sorry, should be downgrade=True to not break existing applications.
>
> Regards, Clodoaldo Pinto Neto
>

And test not downgrade:

    def parse(Class, s, secret, downgrade=False, strict=False):

       dict = _parse_cookie(s, Class)

       del_list = list()
       for k in dict:
           c = dict[k]
           try:
               c.unmarshal(secret)
           except (CookieError, ValueError):
              if not downgrade:
                  del_list.append(k)
              else:
                  if strict:
                      raise
                  else:
                      # downgrade to Cookie
                      dict[k] = Cookie.parse(Cookie.__str__(c))[k]

       for k in del_list:
           del dict(k)
       return dict

Regards, Clodoaldo Pinto Neto


More information about the Mod_python mailing list