[Zope] Restarting Zope makes Values in python class disappear
Evan Simpson
evan@digicool.com
Thu, 30 Mar 2000 17:51:45 -0500
----- Original Message -----
From: Mark N. Gibson <mark@ifopen.com>
> I've got a simple python class that has a data member that holds a list of
> strings (among other things). I can laod values into this list fine.
> And can query the object and the list is populated. However, after I
> restart Zope, the list for the class instance is empty. The other data
> values in my class retain their values just fine.
You're probably mutating the list without informing the instance that you've
changed it. If you do:
thing.stufflist[4] = 'newstring'
or
thing.stufflist.append('newstring')
...then 'thing' has no way of knowing that 'stufflist' has changed, unless
you replace 'stufflist':
# This can be confusing, since it doesn't look like it does anything
thing.stufflist = thing.stufflist
... or tell 'thing' explicitly:
# This is the official interface to mark an object changed
thing._p_changed = 1
Your changes will also get saved if you happened to change any other
attributes of 'thing' in the same transaction, but as you've discovered this
is unreliable at best. Explicit is better.
Cheers,
Evan @ digicool & 4-am