[Zope3-dev] RE: [Zope3-Users] Cannot Pickle

Roger Ineichen dev at projekt01.ch
Wed Mar 9 05:48:29 EST 2005


Hi Marc

> -----Original Message-----
> From: zope3-users-bounces at zope.org 
> [mailto:zope3-users-bounces at zope.org] On Behalf Of Marc Rijken
> Sent: Wednesday, March 09, 2005 11:28 AM
> To: jim at zope.com
> Cc: zope3-users at zope.org
> Subject: Re: [Zope3-Users] Cannot Pickle
> 
> 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()

try:

class TopicMap(BTreeContainer, TopicMapObject):

    def __init__(self):
        super(TopicMap. self).__init__()

    def createTopic(self, name):
        topic = Topic()
        super(TopicMap, self).__setitem__(name, topic)


Regards
Roger Ineichen

> 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
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
> 



More information about the Zope3-dev mailing list