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

Joachim Schmitz js@aixtraware.de
Thu, 20 Jun 2002 15:48:13 +0200


Hi,

I have a python-script getArtikel, which return items from a=20
ZPatterns-Rack, like so:


item=3Dcontext.getItem("theItemId")
return item

this works fine, now I want to override some of the attributes of the item:

item=3Dcontext.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 solved that problem by creating a dictionary, and "copying" the=20
attributes into it.
but now - of course - my python expressions
python: here.getArtikel.date.strftime('%d.%m.%Y')
in the pagetemplates complain that there is no attribute "date", and I have =

to change all those attribute references to=20
here.getArtikel['date'].strftime('%d.%m.%Y')

I know that I cannot change object-attributes in scripts. Is there a simple =

solution for this ? Or is it simply not possible ?



Mit freundlichen Gr=FC=DFen                              Joachim Schmitz
--------------------------------------------------------------------
AixtraWare Ingenieurb=FCro f=FCr Internetanwendungen
H=FCsgenstr. 33a, D-52457 Aldenhoven
Telefon: +49-2464-8851, FAX: +49-2464-905163
--------------------------------------------------------------------
Key fingerprint =3D DA10 CC82 62F8 1DBB 39A1  1EDC 725B 3317 A8D7 C3A6
Keyserver: http://www.keyserver.net/en/