[Zope] Problems with tokens disappearing

Dieter Maurer dieter@handshake.de
Mon, 2 Jul 2001 20:42:40 +0200 (CEST)


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