Class problem: loosing my mind

stuffduff stuffduff at cox.net
Sun Apr 27 10:49:43 EDT 2003


I think I'm getting this now, and my zope example works.

Lessons learned:

Zope External Methods are not really python modules, so zope can read
a function from from a module without seeing a class definition
contained in the module.

Class pickles have a reference to the cass definition embedded in
them.  If you look at the pickle you can see the reference at the
start of the pickle.  Import errors that occur when unpickling a class
mean that pickle can't find the class definition that was used when
the object was pickled.

So when pickling a class, it's best for the class to be in a module
and the module in a package.  Then import the class definition into
both the pickling and unpickling modules, pickle sees class reference
the same way during both processes.

When package and module names are the same, import
constructs the reference with an unexpected behavior, 
which can be resolved by:

from {package} import {module}

Thanks to Andrew and Erik for their help!

Sean

'Onomonopia!' -- The Three Stooges






More information about the Python-list mailing list