[ZODB-Dev] Confusion about persistent dictionaries / lists

Andrew Kuchling akuchlin@mems-exchange.org
Tue, 3 Jul 2001 15:33:36 -0400


On Tue, Jul 03, 2001 at 03:22:24PM -0400, Jeff Sasmor wrote:
>For example, in one Zope product I recently
>finished (Blark weblog) I used lots of
>(ordinary) lists and dictionaries and they
>seem to go in and out of the ZODB with
>no problem even though I don't use Perisistent
>List or Mapping. 

They get pickled and written out without problems, but modifying a
regular list or dictionary wouldn't set the object's dirty bit, so if
that's the only change, the changes would be lost.  As an experiment,
try modifying just an object's dictionary attribute, do a commit(),
and then start a new process.  That is, try something like this:

obj.dict = {}
commit()
obj.dict[1] = 'a'
# obj._p_changed will still be 0.
commit()
# Run a new process and see if obj.dict contains anything.

I'd expect that the dictionary modification would never be written
out.  If your code modifies other object attributes as well as a
dictionary or list attribute, then this bug will be disguised.

--amk