Re: [ZODB-Dev] example for the following?
Am 22.01.2009, 17:46 Uhr, schrieb Jamie McQuay ja...@scimatic.com: Hi, I'm using ZODB in a desktop app (i.e. not using zope). I have class A which contains a list of instances for class B. I can persist class A when the list of class B is empty. When i add an instance of class B to the list (and set _p_changed = 1) i get the error: TypeError: can't pickle PySwigObject objects Can someone please give me a link of some advice in how i go about persisting lists of class instances? It seems you used SWIG to create class B (or you use a library which provides B and the library uses SWIG). By default, instances of classes created by SWIG are not serializable. You'd get the same error if you tried import pickle pickle.dumps( B() ) So what you (or the library author) need to do is add one or more of the methods for serialization explained here: http://www.python.org/doc/2.5/lib/pickle-inst.html http://www.python.org/doc/2.5/lib/node321.html http://www.python.org/doc/2.5/lib/node322.html -Matthias ___ For more information about ZODB, see the ZODB Wiki: http://www.zope.org/Wikis/ZODB/ ZODB-Dev mailing list - ZODB-Dev@zope.org http://mail.zope.org/mailman/listinfo/zodb-dev
Re: [ZODB-Dev] example for the following?
Hello Jamie, I would say to persist that object either you rewrite it in python, (and use the persistent module) or fiddle around the __getstate__ and __setstate__ methods. Though no idea how you can get those working with your swig'ed objects. See: http://docs.python.org/library/pickle.html Thursday, January 22, 2009, 5:46:08 PM, you wrote: JM Hi, JM I'm using ZODB in a desktop app (i.e. not using zope). JM I have class A which contains a list of instances for class B. JM I can persist class A when the list of class B is empty. When i JM add an instance of class B to the list (and set _p_changed = 1) i get the error: JM TypeError: can't pickle PySwigObject objects JM Can someone please give me a link of some advice in how i go JM about persisting lists of class instances? JM Thanks, JM Jamie JM JM ~~~ JM Jamie McQuay JM Scimatic Software Inc. JM www.scimatic.com JM JM We build software for scientists. JM -- Best regards, Adam GROSZERmailto:agros...@gmail.com -- Quote of the day: You will feel hungry again in another hour. ___ For more information about ZODB, see the ZODB Wiki: http://www.zope.org/Wikis/ZODB/ ZODB-Dev mailing list - ZODB-Dev@zope.org http://mail.zope.org/mailman/listinfo/zodb-dev