[albatross-users] pickle problem

Andrew McNamara andrewm at object-craft.com.au
Mon May 2 10:37:21 EST 2005


>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 python-list at python.org - 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/



More information about the Albatross-users mailing list