[Zope-dev] Strange behavior in modifying properties

Martijn Pieters mj@antraciet.nl
Tue, 09 Nov 1999 11:23:38 +0100


At 10:30 09/11/99 , Rik Hoekstra wrote:
>Today I was experimenting a little with inserting and deleting from lines
>properties (though I see no reason why this would not apply to other
>properties. There was some strange behavior with modifying lists from dtml.
>The method was as follows:
>
>
><dtml-var lst>
>
><dtml-call "lst.remove(REQUEST['remove_item'])">
>
><dtml-var lst>
>
>where lst is a property of the containing folder. The proper way to do this
>would be to make a local copy of the list and replacing the property with
>it, but that's not the point.
>
>Now, as far as I'm aware this method should have no effect on the properties
>of the folder, or is it. But is has: it changes the property and it seems to
>have a permanent effect.
>But, as it is not a completed transaction changes are undone if ZServer is
>closed down.
>
>A few questions:
>- has anyone seen this as well
>- could someone explain me how this works
>- is this a bug or a feature
>- if it is a feature - could someone show me its use

You are modifying a mutable list, something the ZODB doesn't detect. This 
is a documented shortcoming of the Persistence mechanism. If you make a 
copy of the list, and put that copy back using editProperties or some such 
API method, the change will be detected and made persistent.

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