[Zope] how to return a new object from a pythonscript ?

Dieter Maurer dieter@handshake.de
Thu, 20 Jun 2002 21:54:46 +0200


Joachim Schmitz writes:
 > I have a python-script getArtikel, which return items from a 
 > ZPatterns-Rack, like so:
 > 
 > 
 > item=context.getItem("theItemId")
 > return item
 > 
 > this works fine, now I want to override some of the attributes of the item:
 > 
 > item=context.getItem("theItemId")
 > setattr(item.text,item.text_english) # the attribute text_english exists
 > return item
 > 
 > but that results in an error: attributeless object assign or del.
I would expect a TypeError, as "setattr" has three parameters:
object, attribute name and value. Try:

	setattr(item,'text',item.text_english)


Dieter