[Zope] Add a new atrribute to a record

Marcel Preda marcel@punto.it
Mon, 10 Jul 2000 15:13:00 +0200


Hi I have a variable `x' ,
type is `instance' -record-,
was created with something like
http://host/page?x.attr1:record=Value1

I want to add a new attribute `attr2', in Zope
something similar with:<dtml-call "REQUEST.set('var',Expresion)">
OR
(python ) x.attr2=VALUE2
but the assign operator `=' is not allowed in Python expresion,
so I can not call <dtml-call "x.attr2=VALUE2">

So I try:
<dtml-call "x.__dict__.update({'attr2':'attrValue'})">
(the expresion in Python is (VERY) correct)

When I try to save the DTML-METHOD ,
(NOT at the EXECUTION time), I get the error:

#######
...
...
  File /usr/lib/zope/lib/python/DocumentTemplate/DT_Util.py, line 357, in
name_param
    (Info: ({'': '&quot;x.__dict__.update({\'attr\':\'attrValue\'})&quot;'},
'call', 1, 'name'))
  File /usr/lib/zope/lib/python/DocumentTemplate/VSEval.py, line 175, in
__init__
    (Object: x.__dict__.update({'attr':'attrValue'}))
TypeError: illegal name used in expression
...
#####

I have take a look at VSEval.py,
and looks like  I can not use names that are starting with `_'
and are  not in ('_', '_vars', '_getattr')


How can I add a new attribute to a variable?
I can do this with an external method,
but maybe exist other way...

Thanks!



PM
_______________________________
"Will I be using Python today?"
 and if the answer is "yes"
 I know that it's going to be a good day.