[Zope] Problems with tokens disappearing

Dieter Maurer dieter@handshake.de
Thu, 5 Jul 2001 00:31:03 +0200 (CEST)


Jay, Dylan writes:
 > If there was a published API. The documentation is all over the place.
Zope embedded Online Help -> API Reference ->
PropertyManager/PropertySheet.

 > Now I have a different problem. My ZClass python script method now looks
 > like this
 > 
 > if username not in context.Members:
 >   context.Members.append(username)
 >   new_members = context.Members
 >   context.propertysheets.Membership.manage_changeProperties(Members =
 > new_members)
 >   return 1
 > return 0
 > 
 > The problem is that this changes the properties of all the objects not just
 > the one I'm interested in. It's as if "context" is the class not the
 > instance. 
Same problem as before!

  Apparently, your ZInstance does not yet have defined its own
  "Members" property. Therefore it inherits the one of the
  ZClass.

  The "context.Members.append" modifies *THIS* (i.e. the ZClass')
  Members object. All other instances (that did not yet
  define their own "Members") will see the change
  (until the object is flushed from the cache; then
  they will revert back).

You should use:

    new_members= context.Members + [username]
    context.propertysheets.Membership.manage_changeProperties(Members= new_members)


Be careful, not to modify shared objects.


Dieter