[Zope] can't delete most recently added key from a Persistent dictionary

Roman Milner roman@speeder.com
12 Sep 1999 12:47:54 -0500


Hello again.  I changed self.fields to be a PersistentMapping() rather 
than a dictionary.  This did not help - and I was sure that it woudl
:(  Please help!

^Roman


>>>>> "RM" == Roman Milner <roman@speeder.com> writes:

    RM> Hello.  I have a problem trying to use the Persistent mixin
    RM> class. I have a dictionary attribute that holds configurable
    RM> fields.  The fields are added like this:

    RM> 	def store_new_fields(self, REQUEST): f = self.fields if
    RM> hasattr(REQUEST, 'abstract_p'):
    RM> f[string.strip(REQUEST.new_item_name)] = {'type':
    RM> REQUEST.dtype, 'abstract_p': REQUEST.abstract_p} else:
    RM> f[string.strip(REQUEST.new_item_name)] = {'type':
    RM> REQUEST.dtype, 'abstract_p': 0} self.fields = f


    RM> I then delete items thusly:

    RM> 	def del_fields(self, the_fields): f = self.fields if
    RM> type(the_fields) == type(""): del(f[the_fields]) else: for
    RM> fname in the_fields: del(f[fname]) self.fields = f


    RM> This mostly works fine except the most recently added new
    RM> field can not be deleted.  The del() call does not raise an
    RM> error but when I look at self.fields.keys() after calling
    RM> del_fields() on the most recently added field - it still
    RM> exists.

    RM> I'm sure there is something with the persistence stuff that I
    RM> am missing.  Any help would be greatly appreciated.


    RM> Thanks, ^Roman

    RM> _______________________________________________ Zope maillist
    RM> - Zope@zope.org http://www.zope.org/mailman/listinfo/zope

    RM> (To receive general Zope announcements, see:
    RM> http://www.zope.org/mailman/listinfo/zope-announce

    RM> For developer-specific issues, zope-dev@zope.org -
    RM> http://www.zope.org/mailman/listinfo/zope-dev )