[mod_python] Session Pickling Error II - 3.2.2b

Nicolas Lehuen nicolas.lehuen at gmail.com
Tue Oct 4 01:43:51 EDT 2005


Graham,

Mr Gator Aide had the same problem with mod_python 3.1.4, though the message
was a bit different. The point is that he is trying to store too much in the
session and that he should work around that. The new import mechanism may
make things a little more difficult, but the core problem is in the way he
uses sessions, not in mod_python.

Regards,
Nicolas

2005/10/4, Graham Dumpleton <grahamd at dscpl.com.au>:
>
> GATOR AIDE wrote ..
> > After updating mod_python 3.1.4 to 3.2.2b I am getting
> > an error:
> >
> > PythonHandler mod_python.publisher: TypeError: can't
> > pickle function objects
> >
> > I am storing a function in the session and calling
> > session.save(). (Which is when the error is raised.)
> >
> > Using mod_python 3.1.4 the code works just fine but
> > after the update I am now seeing this error.
> >
> > The code simply stores a dictionary and few function
> > callbacks in the session and loops through several
> > functions until it is done processing.
> >
> > Not sure if anyone else has had this problem? I
> > running centos 2.4.21-27.0.4.ELsmp on a x86_64
> > platform. Python 2.4.2 (same error w/2.4.1). Apache
> > 2.0.46.
> >
> > I wasn't sure if this is the right place to post this,
> > so I apologize if I should have posted the question
> > elsewhere.
>
> I am going to hazard a guess and say that pickle probably only allows
> you to pickle a function objects where the function object resides in a
> module which was imported using "import", ie., lives in " sys.modules".
>
> In mod_python 3.2, mod_python.publisher handler modules are no longer
> imported using the Python "import" mechanism but are instead read in as
> strings and executed against a dictionary of an empty module which does
> not actually exist in sys.modules.
>
> def build(self, key, name, opened, entry):
> try:
> module = new.module(re_not_word.sub('_',key))
> module.__file__ = key
> exec opened in module.__dict__
> return module
> finally:
> opened.close()
>
> The error would seem reasonable under these circumstances because if it
> were pickled, it wouldn't perhaps be unable to unpickle it later as it
> wouldn't know the name of a module in "sys.modules" to associate the
> function reference to.
>
> Are you sure you can't use a string reference or something else as a
> handle
> to refer to the callback function rather than an actual function object?
>
> Graham
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20051004/39d1a977/attachment.html


More information about the Mod_python mailing list