[mod_python] Can i have both Marshal and Signed Cookies with Publisher?

Clodoaldo Pinto Neto clodoaldo.pinto at gmail.com
Sun Oct 29 15:41:05 EST 2006

If i set both a Signed and a Marshal cookie and try to retrieve the
Marshal one using the Publisher i get this error:

Mod_python error: "PythonHandler mod_python.publisher"

Traceback (most recent call last):

  File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line
299, in HandlerDispatch
    result = object(req)

  File "/usr/lib/python2.4/site-packages/mod_python/publisher.py",
line 213, in handler
    published = publish_object(req, object)

  File "/usr/lib/python2.4/site-packages/mod_python/publisher.py",
line 412, in publish_object
    return publish_object(req,util.apply_fs_data(object, req.form, req=req))

  File "/usr/lib/python2.4/site-packages/mod_python/util.py", line
439, in apply_fs_data
    return object(**args)

  File "/var/www/html/teste/python/publisher/marshalcookie.py", line
10, in index
    marshal_cookies = Cookie.get_cookies(

  File "/usr/lib/python2.4/site-packages/mod_python/Cookie.py", line
350, in get_cookies
    return Class.parse(cookies, **kw)

  File "/usr/lib/python2.4/site-packages/mod_python/Cookie.py", line
252, in parse

  File "/usr/lib/python2.4/site-packages/mod_python/Cookie.py", line
280, in unmarshal
    self.value = marshal.loads(base64.decodestring(self.value))

  File "/usr/lib/python2.4/base64.py", line 319, in decodestring
    return binascii.a2b_base64(s)

Error: Incorrect padding

If the Signed cookie is deleted then the Marshal cookie can be
retrieved with no errors.

The scripts that trigger the error are:

Set and retrieve the Signed cookie:

Set and retrieve the Marshal cookie:

I'm just building that tutorial. BTW i would appreciate to have it
corrected by the experts.

I tested in Firefox and Opera 9.02. FC5, mod_python 3.2.8, Apache 2.2.2.

Regards, Clodoaldo Pinto Neto

More information about the Mod_python mailing list