[Zope] can't delete most recently added key from a Persistent dictionary
Roman Milner
roman@speeder.com
12 Sep 1999 05:23:26 -0500
Hello. I have a problem trying to use the Persistent mixin class. I
have a dictionary attribute that holds configurable fields. The
fields are added like this:
def store_new_fields(self, REQUEST):
f = self.fields
if hasattr(REQUEST, 'abstract_p'):
f[string.strip(REQUEST.new_item_name)] = {'type': REQUEST.dtype,
'abstract_p': REQUEST.abstract_p}
else:
f[string.strip(REQUEST.new_item_name)] = {'type': REQUEST.dtype,
'abstract_p': 0}
self.fields = f
I then delete items thusly:
def del_fields(self, the_fields):
f = self.fields
if type(the_fields) == type(""):
del(f[the_fields])
else:
for fname in the_fields:
del(f[fname])
self.fields = f
This mostly works fine except the most recently added new field can
not be deleted. The del() call does not raise an error but when I
look at self.fields.keys() after calling del_fields() on the most
recently added field - it still exists.
I'm sure there is something with the persistence stuff that I am
missing. Any help would be greatly appreciated.
Thanks,
^Roman