[Zope] What kind of attributes can be put inside a simple item

Marco Bizzarri m.bizzarri at icube.it
Fri Feb 18 10:25:09 EST 2005


Andreas Jung wrote:
> 
> 
> --On Freitag, 18. Februar 2005 10:36 Uhr +0100 Marco Bizzarri 
> <m.bizzarri at icube.it> wrote:
> 
>> Hi all.
>>
>> I'm little surprised by the possibility to insert non-persistent
>> instances inside persistent object. I mean:
> 
> 
> Who says that?
> 
>>
>> class Alfa:
>>     def __init__(self):
>>         self.x = 1
>>         self.y = 2
>>
>>
>> class Beta(SimpleItem):
>>     def __init__(self):
>>         self.id = 'anId'
>>         self.anAlfa = Alfa()
> 
> 
> This is working fine.
> 
>>
>>
>> I always understood that I could not put Alfa instances inside a Beta
>> class, because the ZODB machinery did not understood how to pickle them.
>> But I did some experiments recently, and it looks like the above example
>> should work.
> 
> 
> The problem with persistent objects is that you should know what you are 
> doing if
> you use *persistent* objects as attributes.
> 
>>
>> Could anyone provide some insight on this topic?
>>
> 
> First tell us what leads you to the *your* opinion.
> 
> -aj

Nobody actually told me that. I get my opinion from some results 
obtained working with persistent and non-persisent objects... it was 
something I was so conviced that I can't remember from where I took it.

What could happen if I use persistent object as attributes of other 
persistent objects?

Regards
Marco


More information about the Zope mailing list