[Zope] what am i doing wrong?

Dieter Maurer dieter@handshake.de
Tue, 12 Feb 2002 22:01:25 +0100


mgapp writes:
 > What am i doing wrong if
 > 
 > newObject =
 > context.manage_addProduct['myProduct'].someClass.createInObjectManager
 > (id = 'test', context.REQUEST)
 > 
 > works fine and
 > 
 > zclass = someClass
 > newObject =
 > context.manage_addProduct['myProduct'][zclass].createInObjectManager (id
 > = 'test', context.REQUEST)
 > 
 > raises an Attribute Error?
You confuse "attribute access syntax" and "subscription syntax".
At some places, Zope tries to hide such confusion but not everywhere :-)

Attribute access:
	  "object.attribute" (static form)
  or
	  "getattr(object,attribute_name_expression [, default])" (computed form)

Subscription:

	  object[key_expression]

Consequence: you use

    getattr(context.manage_addProduct['myProduct'], 'someClass').createInObjectManager(....)



Dieter