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

Martijn Pieters mj@antraciet.nl
Sun, 12 Sep 1999 14:53:54 +0200


At 12:23 12-9-99 , Roman Milner wrote:


>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

I think you are running into a problem with transactions here. Changes to 
persistant data only will really happen when you commit the transaction. 
Before this commit, you will not actually see the changes you made.

--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| T: +31 35 7502100 F: +31 35 7502111
| mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
---------------------------------------------