Hi, I have a problem with a class I wrote where I have a list as an attribute of the class. When I append something to that list, it stays there at first, but only until I restart Zope. It disappears (==is set to the value I assigned to it in __init__) and reappears as well when I hit reload a few times very quickly. Whenever I flush the cache it disappears immediately. There seems to be no transaction registered by Zope, because it doesn't show up under 'Undo'. I observed this both thru a dtml page and a debugging function written in python. I attached the code below, the method and attributes I'm talking about are IEEShare.read_access_roles, IEEShare.write_access_roles and IEEShare.add_user_access() The problem exists with both Zope 2.2.0 and 2.2.1b1. I'm running 2.2.1b1 right now on a SuSE Linux 6.4 default installation. (standard libc, threads etc.) Both versions of Zope are compiled from source.
You directly change a nonpersistence participant object. As stated in http://www.python.org/workshops/2000-01/proceedings/papers/fulton/zodb3.html : <quote> All sub-objects of persistent objects must be persistent or immutable. This rule is necessary because, without it, the persistence system would not be notified of persistent object state changes. Like most rules, this rule can be broken with care, as is done in the issue tracking system. A persistent object can use mutable non-persistent sub-objects if it notifies the persistence system that the sub-object has changed. It can do this in two ways. It can notify the persistence system directly by assigning a true value to the attribute _p_changed </quote> so what I think you need is to tell the object wich has the list property that it has changed, coz he can't know it by himself if you list.append or list.extend or even list[0] = something. To do this you can: 1- set self._p_changed = 1 on the object after the change (append or something) 2 - assign self.list to itself so that the object knows a change has been made to that property. but mainly... RTFM ;-) On Wed, 16 Aug 2000, Bob Pepin wrote:
Hi, I have a problem with a class I wrote where I have a list as an attribute of the class. When I append something to that list, it stays there at first, but only until I restart Zope. It disappears (==is set to the value I assigned to it in __init__) and reappears as well when I hit reload a few times very quickly. Whenever I flush the cache it disappears immediately. There seems to be no transaction registered by Zope, because it doesn't show up under 'Undo'. I observed this both thru a dtml page and a debugging function written in python.
I attached the code below, the method and attributes I'm talking about are IEEShare.read_access_roles, IEEShare.write_access_roles and IEEShare.add_user_access()
The problem exists with both Zope 2.2.0 and 2.2.1b1. I'm running 2.2.1b1 right now on a SuSE Linux 6.4 default installation. (standard libc, threads etc.) Both versions of Zope are compiled from source.
-- "Sometimes I think the surest sign that intelligent life exists elsewhere in the Universe is that none of it has tried to contact us." Carlos Neves cneves@ruido-visual.pt
On Wed, Aug 16, 2000 at 05:31:29PM +0100, Carlos Neves wrote:
You directly change a nonpersistence participant object. As stated in http://www.python.org/workshops/2000-01/proceedings/papers/fulton/zodb3.html : [...] but mainly... RTFM ;-)
Well, thanks, but too bad the only FM I've been able to find about Zope are those .py files in lib/python/... I spent a whole day looking for documentation on ZODB internals on zope.org and zdp.zope.org, without being able to find anything... how about adding that paper to the search engine on zope.org? Is there more documentation like that one out there?
Bob Pepin wrote:
On Wed, Aug 16, 2000 at 05:31:29PM +0100, Carlos Neves wrote:
You directly change a nonpersistence participant object. As stated in http://www.python.org/workshops/2000-01/proceedings/papers/fulton/zodb3.html : [...] but mainly... RTFM ;-)
Well, thanks, but too bad the only FM I've been able to find about Zope are those .py files in lib/python/...
I spent a whole day looking for documentation on ZODB internals on zope.org and zdp.zope.org, without being able to find anything... how about adding that paper to the search engine on zope.org? Is there more documentation like that one out there?
a couple actually, not located so that you can find them but they exist jim fulton's paper from the ipc8 (python conference) is excellent reading material. http://www.zope.org/Members/jim/Info/IPC8/ZODB3News also the uml models http://www.zope.org/Documentation/Developer/Models/ZODB/ and another excellent paper by andrew kuchling on zodb and ZEO http://starship.python.net/crew/amk/python/writing/zodb-zeo.html there is also a how-to... Cheers Kapil
On Wed, 16 Aug 2000, Bob Pepin wrote:
attribute of the class. When I append something to that list, it stays there at first, but only until I restart Zope. It disappears (==is set
You have to let Zope know that the object has been modified so it knows to commit it to disk. x = self.list x.append('something') self.list = x will do that. Hmm. Actually I suppose that self.list.append('something') self.list = self.list would also work. (The point is for __setattr__ to get called so Zope can notice that the object has changed). There's also a property you can set on self to notify zope of the modification, but I forget it's name. --RDM
that property would be set by calling... self._p_changed = 1 right after you changed anything in that list. jens on 8/16/00 9:37, R. David Murray at bitz@bitdance.com wrote:
On Wed, 16 Aug 2000, Bob Pepin wrote:
attribute of the class. When I append something to that list, it stays there at first, but only until I restart Zope. It disappears (==is set
You have to let Zope know that the object has been modified so it knows to commit it to disk.
x = self.list x.append('something') self.list = x
will do that. Hmm. Actually I suppose that
self.list.append('something') self.list = self.list
would also work. (The point is for __setattr__ to get called so Zope can notice that the object has changed).
There's also a property you can set on self to notify zope of the modification, but I forget it's name.
participants (5)
-
Bob Pepin -
Carlos Neves -
Jens Vagelpohl -
Kapil Thangavelu -
R. David Murray