[Zope3-Users] Cannot Pickle

Marc Rijken marc at rijken.org
Wed Mar 9 05:27:37 EST 2005


Jim Fulton wrote:
> Marc Rijken wrote:

<snip>

> I just tried this code, after adding the missing imports, and didn't get
> an error, so, obviously, you aren't giving us the whole story. :)

Hi Jim,

Posting the complete code, is too long. So I made an abstract summary. I 
  have made a less abstract summary:

from persistent import Persistent
from zope.app.container.btree import BTreeContainer
from zope.app.container.contained import Contained

class TopicMapObject(Persistent):
     pass

class TopicMap(BTreeContainer, TopicMapObject):
    def createTopic(self, name):
        self[name] = Topic()

class Topic(TopicMapObject, Contained):
    type=None

tm = TopicMap()
tm.createTopic('t1')
tm.createTopic('t2')
tm['t2'].type = tm['t1']

This code performs well if I execute it not as part of a zope3 instance. 
When I put it in a zope3 instance, when tm is put in a ZODB folder and 
when the steps are performed in separate sessions I get the Cannot 
Pickle error at the last step. I hope this extra info will help you to 
help me.

(I have an alternative solution by putting the name of the topic in the 
type, so a string will be pickled. But the other solution is my prefered 
one and I hope that that will work too.)

Thanx!

Marc


More information about the Zope3-users mailing list