[mod_python] Session Pickling Error II - 3.2.2b

Nicolas Lehuen nicolas.lehuen at gmail.com
Tue Oct 4 02:32:05 EDT 2005


As I've wrote in my previous mail, the new error is due to the way
mod_python imports the published modules in 3.2. The new way was designed to
solve a whole bunch of problems. Then again I must confess I had not
foreseen the pickling problem it would cause.

I'll report this problem as a bug against 3.2.2beta. The problem is that
this will not be easily fixed in 3.2. We (the development team) were
prepared to do a major overhaul of the import mechanism for the 3.3 release.
Solving the pickling problem would require that. Right now I can't see any
way to solve this easily in 3.2 while still retaining all the fixes the new
import system has brought.

In the meantime, my advice is that either you keep on using 3.1.4 (living
with its bugs), or work around the pickle problem using one of the solutions
I've wrote before. Maybe the solution where you define your functions and
classes that need to be pickled in a separate module found on the python
path is the easiest one.

Sorry for the inconvenience, and thanks for the bug report.

Nicolas

2005/10/4, GATOR AIDE <gator_aide2000 at yahoo.com>:
>
> Actually, the same exact code works using mod_python
> version 3.1.4.
>
> I only get get the error when I run the code using the
> latest version of mod_python (3.2.2b).
>
> I guess I can work around the problem by storing
> strings or something, but it seems odd that I only get
> the error with the newest version.
>
> Sorry if that wasn't clear in the original post.
>
> Thanks for all of the feedback.
>
> Mike
>
> --- Nicolas Lehuen <nicolas.lehuen at gmail.com> wrote:
>
> > 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
> > >
> >
>
>
>
>
> __________________________________
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> http://mail.yahoo.com
> _______________________________________________
> 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/758d2f6e/attachment.html


More information about the Mod_python mailing list