From: Edward Muller

>I am working on a product in which one of the objects keeps an array. I've
>already overcome the problems with making the array persistent (i.e. by not
>using .append, but intead re-assigning the array each time). Anyway...I
>digress..

It is probably easier to write:

self._p_changed = 1 # Trigger persistence

at the end of a method where you use mutable properties.

the:
tempList = self.contentList
tempList.append(newContent)
self.contentList = tempList

gets tired real fast especially if you have more than one list you need to
update.

self.contentList.append(newContent)
self._p_changed = 1

Is so much simpler, and makes the code much easier to read.

A way you might cheat persistence could be to (untested):

self.id = self.id

But then again, why do that when you only need to set _p_change to true.

The persistence doesn't get triggered for every parameter. Either an object
has changed or it hasn't. So you don't have to trigger it individually for
every list or whatever you use in your object.

regards Max M

Max M. W. Rasmussen,    Denmark.   New Media Director
private: [EMAIL PROTECTED] work: [EMAIL PROTECTED]
-----------------------------------------------------
Specialization is for insects.  -  Robert A. Heinlein


_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
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 )

Reply via email to