Hi, I currently use Zope-2.5.1 and started to develop a new product. This product have internal properties which are common strings or integers, but also instances of internal classes which are stored in lists and dictionnaries. Everythink works fine, until I restart Zope or make a 'refresh' on my product : then, these internal properties are lost !! What should I do to be able to keep these properties ?? Thanks for any help, Thierry -- Linux every day, keeps Dr Watson away... http://gpc.tuxfamily.org -- http://www.ulthar.net
Thierry Florac wrote:
Hi,
I currently use Zope-2.5.1 and started to develop a new product. This product have internal properties which are common strings or integers, but also instances of internal classes which are stored in lists and dictionnaries.
Everythink works fine, until I restart Zope or make a 'refresh' on my product : then, these internal properties are lost !!
What should I do to be able to keep these properties ??
Look into the Zope Developers Guide. Making properties permanent is described there. the main idea is: if you changed a internal property, do a self-assignment. example: self.listProperty.append('hello') self.listProperty = self.listProperty this will make your changes permanent. cheers, maik -- Maik Jablonski __o www.zfl.uni-bielefeld.de _ \<_ Deutsche Zope User Group Bielefeld, Germany (_)/(_) www.dzug.org
At 23:14 2002-10-08 +0200, Maik Jablonski wrote:
Thierry Florac wrote:
Hi, I currently use Zope-2.5.1 and started to develop a new product. This product have internal properties which are common strings or integers, but also instances of internal classes which are stored in lists and dictionnaries. Everythink works fine, until I restart Zope or make a 'refresh' on my product : then, these internal properties are lost !! What should I do to be able to keep these properties ??
Look into the Zope Developers Guide. Making properties permanent is described there.
the main idea is: if you changed a internal property, do a self-assignment.
example:
self.listProperty.append('hello')
self.listProperty = self.listProperty
this will make your changes permanent.
Yes, also be careful with your base classes. You need to inherit the Persistance class which is included in OFS.Folder and ObjectManager and SimpleItem. Peter
cheers, maik
-- Maik Jablonski __o www.zfl.uni-bielefeld.de _ \<_ Deutsche Zope User Group Bielefeld, Germany (_)/(_) www.dzug.org
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
--- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.391 / Virus Database: 222 - Release Date: 2002-09-19
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.391 / Virus Database: 222 - Release Date: 2002-09-19
Hi, On Wed, 2002-10-09 at 01:47, Peter Bengtsson wrote:
Yes, also be careful with your base classes. You need to inherit the Persistance class which is included in OFS.Folder and ObjectManager and SimpleItem.
My product class is inherited from SimpleItem, and so from Persistent. But do you mean also that internal fields should also inherit from Persistent instead of being simple classes ?? I've found also (after sending my mail :-(( ) that it's also possible to use the "self._p_changed = 1" instruction to store these kinds of properties. What's the best way to use ?? Thanks, Thierry
Thierry Florac wrote:
Hi,
On Wed, 2002-10-09 at 01:47, Peter Bengtsson wrote:
Yes, also be careful with your base classes. You need to inherit the Persistance class which is included in OFS.Folder and ObjectManager and SimpleItem.
My product class is inherited from SimpleItem, and so from Persistent. But do you mean also that internal fields should also inherit from Persistent instead of being simple classes ??
no.
I've found also (after sending my mail :-(( ) that it's also possible to use the "self._p_changed = 1" instruction to store these kinds of properties. What's the best way to use ??
depends on your coding-taste...;-) -- Maik Jablonski __o www.zfl.uni-bielefeld.de _ \<_ Deutsche Zope User Group Bielefeld, Germany (_)/(_) www.dzug.org
On Wed, 2002-10-09 at 01:47, Peter Bengtsson wrote:
Yes, also be careful with your base classes. You need to inherit the Persistance class which is included in OFS.Folder and ObjectManager and SimpleItem.
My product class is inherited from SimpleItem, and so from Persistent. But do you mean also that internal fields should also inherit from Persistent instead of being simple classes ??
That should be enough. As long as you inherit from SimpleItem you shouldn't have to do something else.
I've found also (after sending my mail :-(( ) that it's also possible to use the "self._p_changed = 1" instruction to store these kinds of properties. What's the best way to use ??
That shouldn't be necessary. As long as you use the Persistance class and save properties as instructed in a previous email you should be fine. Won't work: def addName(self,name): self.names.append(name) Will work: def addName(self,name): all_names = self.names all_names.append(name) self.names = all_names
Thanks,
Thierry
--- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.391 / Virus Database: 222 - Release Date: 2002-09-19
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.391 / Virus Database: 222 - Release Date: 2002-09-19
participants (3)
-
Maik Jablonski -
Peter Bengtsson -
Thierry Florac