ZODB and COM Server - how to create collection attribute?
Mark Hammond
MarkH at ActiveState.com
Sun Aug 26 18:44:42 EDT 2001
Gerhard Kalab wrote:
> I'd like to write a COM-Server and use ZODB for persistence.
>
> The following code doesn't work, because the class Person has a
> COM-collection (books) which cannot be pickled.
> It would be easy to change the books attribute to get and set COM-methods to
> get and set the books list. But is it possible to use a COM-attribute?
> Is there any way I can change the books list to a list of normal python
> objects before it is going to be saved? And can I change it back to a
> COM-collection after the list is loaded by ZODB?
> Any other ideas?
Your best bet is probably to implement an __getstate__ and __setstate__
methods on your class. This code could unwrap the COM collection, and
re-wrap as necessary. Check out the documentation on pickle and/or the
copy module for more details...
Mark.
More information about the Python-list
mailing list