persistence problem with python product
hello I made a python product class which inherits from Folder and is persistent. Then ive made a helper class, see the listing (ive tried with and without inheriting Persistent) , the CommonPropertyContainer is now an attribute of a Class called Site: class CommonPropertyContainer(Persistent): "a container for properties" def __init__(self,id,title): self.id=id self.title=title self._properties = {} def setProperty(self,id,title,value): self._properties[id] = {"title":title,"value":value} def setPropertyValue(self,id,value): self._properties[id]['value'] = value def getProperties(self): return self._properties.items() ___________________________________________________ now when i change values via the setPropertyValue(method) the new values get lost when I restart zope I dont know but I heard that objects used by a class which is persistent are automatically persistent too please help
def setProperty(self,id,title,value): self._properties[id] = {"title":title,"value":value}
self._p_changed=1
def setPropertyValue(self,id,value): self._properties[id]['value'] = value
self._p_changed=1
now when i change values via the setPropertyValue(method) the new values get lost
You forgot the two lines above. Also, why don't you just use normal properties/propertysheets? cheers, Chris
wow - very fast response !! it works now - thanks a lot i couldnt find a documentation for the propertysheets stuff (see Thread:"[Zope] Propertysheets in python products") from today) and after reading the sourcecode i thought it would be faster if i do it by myself maybe i'll try the other way sometime when i'm more experienced with zope this is my first "python only" product :) thx ----- Original Message ----- From: "Chris Withers" <chrisw@nipltd.com> To: "zope-mailinglist" <zope-mailinglist@mopa.at>; <zope@zope.org> Sent: Wednesday, April 18, 2001 10:50 PM Subject: Re: [Zope] persistence problem with python product
def setProperty(self,id,title,value): self._properties[id] = {"title":title,"value":value}
self._p_changed=1
def setPropertyValue(self,id,value): self._properties[id]['value'] = value
self._p_changed=1
now when i change values via the setPropertyValue(method) the new values get lost
You forgot the two lines above.
Also, why don't you just use normal properties/propertysheets?
cheers,
Chris
i couldnt find a documentation for the propertysheets stuff (see Thread:"[Zope] Propertysheets in python products") from today) and after reading the sourcecode i thought it would be faster if i do it by myself
Try searching your Zope servers built-in help for 'property' ;-) Alternatively: http://www.zope.org//Members/michel/Projects/Interfaces/PropertyManager ...will tell you all you need to know. cheers, Chris
participants (2)
-
Chris Withers -
zope-mailinglist