[Zope] object references in python (script)

Dieter Maurer dieter@handshake.de
Wed, 7 Nov 2001 23:52:02 +0100


Hans N. Beck writes:
 > I've no idea where may be an error at the folling code:
 > 
 > ----
 >  # create a unique  id
 >  id= str(linkname) + str( len(context.objectIds()))
 > 
 >  # add new instance of DokuTypeID (hint from mailing list)
 >  context.REQUEST.set('id', id)
 >  my_context= context.manage_addProduct['DokuItem']
 >  my_context.DokuTypeID_add(my_context,context.REQUEST, NoRedir=1)
 > 
 >  # add a guest_name string property (variant of the guestbook example in
 > Zope Book)
 >  context.REQUEST.set('keyword',id)
 >  doc=getattr(context, id)
 >  doc.manage_changeProperties(context.REQUEST)
 > ----
 > 
 > DokuItem is a own product, containing the class DokuTypeID, which has
 > the property 'keyword'. Assume the code has to create an instance
 > in folder "anything". Instance is created - good. But not the
 > property of the new DokuTypeID instance is set, the property of
 > the folder "anything" (which also has the property "keyword") is
 > overwritten. ??????? So it seems, the variable doc points to the
 > folder object, not to the new instance in it. Why ????
Apparently, your "doc" does not have a method "manage_changeProperties"...
Therefore, it is acquired.


Dieter