object references in python (script)
Hi all, 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 ???? Thanks for help! Greetings Hans ----------------------------------- Dipl.-Ing. Hans N. Beck Waldstr. 28 75045 Walzbachtal Tel: 07203/922280 Mobil: 0177/5383233 -----------------------------------
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
Hi,
Apparently, your "doc" does not have a method "manage_changeProperties"... Therefore, it is acquired.
Dieter
Ahhh ! Ok, but DokuItemType has Base class Object manager, so it should have such method ??? If not, how must I implement this method ? Greetings Hans
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Hans N. Beck writes:
Ahhh ! Ok, but DokuItemType has Base class Object manager, so it should have such method ??? If not, how must I implement this method ? No, an Object Manager does not have methods of a Property Manager...
You derive from PropertyManager, too.... Dieter
Hi,
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of Dieter Maurer Sent: Thursday, November 08, 2001 9:43 PM To: Hans N. Beck Cc: Zope@Zope. Org Subject: RE: [Zope] object references in python (script)
Hans N. Beck writes:
Ahhh ! Ok, but DokuItemType has Base class Object manager, so it should have such method ??? If not, how must I implement this method ? No, an Object Manager does not have methods of a Property Manager...
You derive from PropertyManager, too....
from this doing a blind trial: doc=getattr(my_context, id) doc.propertysheets.DokyTypePropertiesID.manage_changeProperties(my_conte xt.R EQUEST) is the solution. uff ! But why works the Zope Book example doc.manage_changeProperties(my_context.REQUEST) ?? Here there get my basic problem understanding zope visible: understanding which objects contains which other an how to get references to or accesing instances. For me as beginner it's not easy. This is especially true for the somewhat mystic (at beginning) Context and REQUEST objects. Many Zope examples only say: "do this", but not "do this is why". Greetings Hans
participants (2)
-
Dieter Maurer -
HNBeck@t-online.de