[Zope3-Users] store persistent objects

Alek Kowalczyk thealx at poczta.onet.pl
Wed Jun 21 13:35:46 EDT 2006


Leticia Larrosa wrote:
> Hi all
>
> To fix the error I must change the __init__ of the BTreeContainer class to
> the follow:
> """
> class persistent_test(BTreeContainer):
>     implements(Ipersistent_test)
>     def __init__(self):
> 	  BTreeContainer.__init__(self)
>         self['un_padre'] = Padre('Lety','Campanilla')
> """
>
> Any idea about store object and list of objects? 
> This way is the right way?
>
>   
I'm not sure if I have understood your problem correctly, but here is
what you probably could do:
For Root: inherit from Persistent and call  __init__ of parent class
(btw: using super(CurrentClass, self) is the recommended way to do that)

class Root(Persistent):
	def __init__(self):
		super(Root, self).__init__()
		self.rootIndex = RootIndex()



For list: use PersistentList instead of list.
For Leave and RootIndex: inherit from Persistent as well (and remember
to call super(...).__init__ if you define own constructor)

Regards,
Alek

> Thanks in advanced
> Leticia Larrosa
>
> -----Original Message-----
> From: zope3-users-bounces at zope.org [mailto:zope3-users-bounces at zope.org] On
> Behalf Of Leticia Larrosa
> Sent: Tuesday, June 20, 2006 11:03 AM
> To: zope3-users at zope.org
> Subject: [Zope3-Users] store persistent objects
>
> Hi all
>
> Resume:
>
> I want to store persistent data in the zope database. I must have an object
> that store others object inside it, including list of objects, etc. I want
> that when I create the root object automatically create object inside it.
>
> Example of python class:
> """
> class Leave:
> 	name = u""
> 	(...)
>
> class RootIndex:
> 	index_list = []
> 	(...)	
> 	
> class Root:
> 	name = u""
> 	rootIndex = None
> 	leave_list = []
> 	
> 	def __init__(self): 
> 		self.rootIndex = RootIndex()
> """
>
>   




More information about the Zope3-users mailing list