Re: pickle problem

Andrew McNamara <[email protected]> Mon, 02 May 2005 10:37:21 +1000
Newsgroups gmane.comp.web.albatross.general
Message-ID <[email protected]>
>ApplicationError: locals "user": Can't pickle <class 'Base.User'>: it's not the same object as Base.User
>
>
>Any idea what the problem is? user of type Base.User is kept in the
>session. This happens sometimes and sometimes it works ok.

You might do better asking on [email protected] - this error is
coming out of cPickle, rather than Albatross (albatross has simply caught
the error and re-raised it to add more diagnostics).

If I had to guess, I would say that the pickler is unable to identify
the code object associated with that class. When you pickle an instance
of a class, only the instance attributes and a reference (the module
and class name) to the class are saved.

You could try renaming your "User" class or the "Base" module temporarily - 
this will tell you if the pickler is stumbling across the wrong module.

If you're playing tricks with the class definition at run-time, this will
also confound the pickler, I think (eg, metaclasses), or maybe changing the
instance's class at run-time.

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/