ZODB: don't like self._p_changed

Thomas Guettler zopestoller at thomas-guettler.de
Thu Jan 9 07:58:49 EST 2003


Max M schrieb:
> Thomas Guettler wrote:
> 
>> Max M schrieb:
> 
> 
>>> Probably not. How should an object know if a mutable subobject has 
>>> been changed?
>>
>>
>> The method "append" could set the flag.
> 
> 
> Then you would need to use specialized objects instead of the built in 
> objects. That would shurely be more cumbersome than setting the 
> persistence flag?

Yes, there a classes like PersistentList and PersistentMapping, but
this means I need to change my code.

Example:

my_list=PersistentList()
my_list.append(...)

my_list=some_other_list[1:] # now my_list is no more a persistent list

This means, I always need to keep in mind if a list is a peristent list
or not. That's like setting _p_changed=1.

1. Solution:

One solution could be to change the meaning of [] and {}.
Dreaming:

import list_persistance
foo=[] # foo is now a persistent list.

I don't know if this is possible.


2. Solution:
Change the functions of list and mapping datatypes to set _p_changed if 
the content was changed. This might decrease performance for 
nonpersistent application. But since there changes need to be 
implemented in the python core, they would be in C.

thomas





More information about the Python-list mailing list