Sounds like you are trying to persist a class attribute value. This is not 
possible because instance are persistent, not classes. This is also the 
reason that the values change over all the instances. You are changing a 
mutable attribute of the class in place.

I would suggest setting the value in the constructor of your objects, to make 
sure it is an instance attribute rather than a class attr.


class foo:
   def __init__(self):
       self.alist = []

   def append(self ,v)
       self.alist.append(v) # changes instance attr
       self._p_changed = 1 # will work

Instead of:

class foo:
    alist = []

    def append(self ,v)
        self.alist.append(v) # changes class(!) attr
        self._p_changed = 1 # Will not work, the instance was not changed!



On Wednesday 18 September 2002 03:27 pm, Arndt Droullier wrote:
> Hello,
> I´m working on a product which contains custom data in a list of multiple
> dictionaries.
> How can I save the list/dictionaries after changes? Persistence is enabled
> (and works for other types), and "_p_changed" is set, also
> get_transaction().commit() is called.
> A second problem is that multiple instances of the product reference the
> same list. So if I change the list of one of the instances the other
> changes,
> too.
> The list and dictionaries are stored in a class variable(in the product)
> and not global.
> Thanks, Arndt.
> _______________________________________________________________________
> DV electric         [EMAIL PROTECTED]
> Fon 0221/2725782    Fax 0221/2725783          Burgmauer 20,  50667 Köln
> _______________________________________________________________________

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to