[mod_python] Pickled objects require _apache on un-pickling (mod_python 3.2.8)

Jim Gallacher jpg at jgassociates.ca
Mon Apr 3 11:52:55 EDT 2006


It sounds like you are using FieldStorage to retrieve your form data, 
and trying to pickle it or some of its fields directly. Loading the 
pickle will then pull in mod_python.util which has the _apache 
dependency. _apache is part of the hook into Apache's guts, and can't be 
used outside of mod_python.

Try building your pickle using form['some_name'].value, which will be a 
string, rather than form['some_value'], which will be an instance of 
mod_python.util.Field.

Jim


Webb Sprague wrote:
> So...
> 
> I have a web application that pickles objects after doing some
> statistical analyses on data that is entered through a form, with a
> mod_python infrastructure.  Now I am trying to unpickle those objects
> in ipython, but I get the strange error "can't find _apache" (see
> stack trace below) on cPickle.loads() (line 108).  It works fine
> through the web browser.  Why would this object possibly want _apache
> or apache -- it doesn't import anything to do with mod_python
> explicitly, and I can create these objects outside of the web.  I can
> post more code or more error messages if it would help
> 
> Thanks!
> 
> In [30]: lcdb.retrieveObject(14)
> ---------------------------------------------------------------------------
> exceptions.ImportError                               Traceback (most
> recent call last)
> 
> /var/www/localhost/htdocs/larry/<ipython console>
> 
> /var/www/localhost/htdocs/larry/LcDB.py in retrieveObject(self,
> objectSerialNumber)
>     106                 if instancePickled == None:
>     107                         raise LcDataException, "No such data
> object: %i" % objectSerialNumber
> --> 108                 instance = cPickle.loads(instancePickled)
>     109                 curs.close()
>     110                 return instance
> 
> /usr/lib/python2.4/site-packages/mod_python/util.py
>      19 # $Id: util.py 374268 2006-02-02 05:31:45Z nlehuen $
>      20
> ---> 21 import _apache
>      22 import apache
>      23 import cStringIO
> 
> ImportError: No module named _apache
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
> 



More information about the Mod_python mailing list