[Twisted-Python] Nested objects in pickle (was: Large projec t (IMS) architecture)
Rick Richardson
rrichardson at eti-main.enabletech.com
Thu Jan 16 12:09:37 MST 2003
that's a good question:
>>> class MyClass:
def __init__(self):
self.blah = 1
>>> class MySecondClass:
def __init__(self):
self.foo = MyClass()
>>> class MyThirdClass:
def MyFunc():
print "test"
>>> bar = MyThirdClass()
>>> bar.foo = MySecondClass()
>>> dir(bar)
['MyFunc', '__doc__', '__module__', 'foo']
>>> pickle.dump(bar, outfile)
|
------
|
\/
(i__main__
MyThirdClass
p0
(dp1
S'foo'
p2
(i__main__
MySecondClass
p3
(dp4
g2
(i__main__
MyClass
p5
(dp6
S'blah'
p7
I1
sbsbsb.
>>> blarg = pickle.load(infile)
>>> dir(blarg)
['MyFunc', '__doc__', '__module__', 'foo']
>>> blarg.foo.foo.blah
1
>>>
The has-a nested relationships seem to work. Is it the is-a that is broken
in pickle? I never knew that to be a nested relationship.
-----Original Message-----
From: twisted-python-admin at twistedmatrix.com
[mailto:twisted-python-admin at twistedmatrix.com]On Behalf Of Patrick K.
O'Brien
Sent: Thursday, January 16, 2003 10:39 AM
To: twisted-python at twistedmatrix.com; Steve Waterbury
Subject: Re: [Twisted-Python] Large project (IMS) architecture
On Thursday 16 January 2003 12:01 pm, Steve Waterbury wrote:
> Itamar Shtull-Trauring wrote:
> > PB actually implements its own version of Pickle as well (jelly)...
>
> And jelly does nested objects, which Pickle can't.
I'm not sure what you mean by that. Could you explain in what way Pickle
can't handle nested objects? Thanks.
--
Patrick K. O'Brien
Orbtech http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------
_______________________________________________
Twisted-Python mailing list
Twisted-Python at twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
More information about the Twisted-Python
mailing list