Hello, I've got a problem with a persistence of created product attributes. My product is a simple CMF portal type containing lists of some objects. The problem is that my lists are flushed after refresh of the product. The question is if all stored elements should be persistent or just main product instance? If not - which elements are affected during the product refresh? Pawel Lewicki
I've got a problem with a persistence of created product attributes. My product is a simple CMF portal type containing lists of some objects. The problem is that my lists are flushed after refresh of the product. The
The list sub-object that doesn't participate in persistence. The normal automatic detection of object changed doesn't work with lists. Either do: self._p_changed=1 or change the whole list, or simply use tuples instead of lists. Read this; http://www.python.org/workshops/2000-01/proceedings/papers/fulton/zodb3.html /Magnus
when you have a persistent object that has attributes of a simple python type (lists, dictionaries, etc) then the persistence machinery cannot automatically tell that the object was changed if you manipulate these attributes. to work around this and explicitly tell the persistence machinery of those changes your code can do one of the following: - reassignment to the attribute in question: mylist = myobj.mylist mylist.append('hello') myobj.mylist = mylist - use the magic _p_changed marker: myobj.mylist.append('hello') myobj._p_changed = 1 hth jens On Tuesday, June 25, 2002, at 08:12 , Pawel Lewicki wrote:
Hello, I've got a problem with a persistence of created product attributes. My product is a simple CMF portal type containing lists of some objects. The problem is that my lists are flushed after refresh of the product. The question is if all stored elements should be persistent or just main product instance? If not - which elements are affected during the product refresh?
Pawel Lewicki
participants (3)
-
Jens Vagelpohl -
Magnus Heino -
Pawel Lewicki