automatic (un-)pickling / overwriting self

sismex01 at hebmex.com sismex01 at hebmex.com
Fri Mar 7 10:18:46 EST 2003


> From: haribeau at gmx.de [mailto:haribeau at gmx.de]
> Sent: Friday, March 07, 2003 9:12 AM
> 
> Hi,
> 
> while working on a cgi-admin interface i got a little problem with
> pickle.
> I use a hierarchical class structure to keep users, permissions, etc.
> As the amount of data is quite small i just pickle the top class
> instance that references the rest.
> I am looking for a way to automatically pickle the top class whenever
> one of the referenced object changes. Furthermore I want a class
> instance to unpickle the data automatically on creation.
> A self = unpickledObject in __init__ does not work (probably a bad
> idea anyway :).
> So how is automatic/implicite serialization(on changes) and
> de-derialization(in __init__) from *within* a class instance done?
> Furthermore: How can I make sure that there can only be one instance
> of the top class active at a time?
> 
> thanks in advance for any hint, rtfm, link, etc.
> 
> /clemens
> 

Hmmm...  "self = otherObject" will only rebind the local variable
"self" to point to another object, it doesn't do anything to the
instance which "self" pointed to previously.

Maybe this helps?

    self.__dict__.update(otherObject.__dict__)

???

-gustavo





More information about the Python-list mailing list