[Zope3-Users] Cannot Pickle

Roger Ineichen dev at projekt01.ch
Wed Mar 9 06:42:37 EST 2005


Hi Marc

Please post the ZCML directive for the content object.

and 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

> -----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 12:38 PM
> To: Marc Rijken
> Cc: zope3-users at zope.org
> Subject: Re: [Zope3-Users] Cannot Pickle
> 
> Maybe the complete error will help:
> 
> Traceback (most recent call last):
>    File 
> C:\Python23\Lib\site-packages\Zope3\src\zope\publisher\publish
> .py", line
>   143, in publish
>      publication.afterCall(request, object)
>    File 
> "C:\Python23\Lib\site-packages\Zope3\src\zope\app\publication\
> browser.py"
> , line 64, in afterCall
>      super(BrowserPublication, self).afterCall(request, ob)
>    File 
> "C:\Python23\Lib\site-packages\Zope3\src\zope\app\publication\
> zopepublica
> tion.py", line 161, in afterCall
>      txn.commit()
>    File 
> "C:\Python23\Lib\site-packages\Zope3\src\transaction\_transact
> ion.py", li
> ne 300, in commit
>      self._commitResources(subtransaction)
>    File 
> "C:\Python23\Lib\site-packages\Zope3\src\transaction\_transact
> ion.py", li
> ne 340, in _commitResources
>      rm.commit(self)
>    File "C:\Python23\Lib\site-packages\Zope3\src\ZODB\Connection.py", 
> line 618, i
> n commit
>      self._store_objects(ObjectWriter(obj), transaction)
>    File "C:\Python23\Lib\site-packages\Zope3\src\ZODB\Connection.py", 
> line 640, i
> n _store_objects
>      p = writer.serialize(obj)  # This calls __getstate__ of obj
>    File "C:\Python23\Lib\site-packages\Zope3\src\ZODB\serialize.py", 
> line 294, in
>   serialize
>      return self._dump(meta, obj.__getstate__())
>    File "C:\Python23\Lib\site-packages\Zope3\src\ZODB\serialize.py", 
> line 303, in
>   _dump
>      self._p.dump(state)
> UnpickleableError: Cannot pickle <type 'zope.security._proxy._Proxy'> 
> objects
> 
> Marc Rijken wrote:
> > 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
> > 
> > 
> 
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
> 



More information about the Zope3-users mailing list