Problems with tokens disappearing
I'm getting this really weird problem with tokens. I have a tokens property of a ZClass (was also happening with a Folder) called Members. I add a new item to this list via a python script using context.Members.append(newitem) I then run the following script members = [] for m in context.Members: user = container.qryGetPersonInfo(username=m) if len(user) == 1: members.append(user[0]) return members and the result keeps changing between an empty list and what it's supposed to be. It's completely weird. ---- Dylan Jay mailto:djay@avaya.com Avaya Communication Tel: +61 2 9886-8961 Level 3, 123 Epping Road FAX: +61 2 9352 9224 Nth Ryde NSW 2113 Mobile: 0409 606 171 AUSTRALIA
Jay, Dylan writes:
I'm getting this really weird problem with tokens. I have a tokens property of a ZClass (was also happening with a Folder) called Members.
I add a new item to this list via a python script using context.Members.append(newitem) You are working around Zope's persistence machinery when you work like this:
A persistent object is able to detect assignments to its attributes. However, it is unable to detect modifications of the attribute value itself without an assignment. In your case, you modify the attribute "Members" without assigning a new value to it. These modifications are not recognized by the persistence machinery. It is very likely that they are lost when the object is flushed from the cache. Always use the published API to modify Zope objects. Do not use internal knowledge, as it may have strange side effects (as in your case) and may break in the future (I hope, that DC will change the lists into tuples; then properties will no longer have an "append"). Dieter
participants (2)
-
Dieter Maurer -
Jay, Dylan