[Zope] no hasattr() in Python Script?
System Administration
root@gunsmoke.ecn.purdue.edu
Wed, 20 Dec 2000 18:08:16 EST
I'm trying to call a Python Script from a
DTML method using
<dtml-var "units.statistics.edit(this())">
in order to edit some numeric properties
of an object. I have "self" as the
parameter list.
If I set the object's property "foo" to
"123" and make edit
return(self.foo)
I get "123". That's good.
I'd like to be able to test if "foo" is
already set, though. It seems obvious
that I should be using hasattr(), but if
I make edit
if hasattr(self, 'foo'):
return('set')
else:
return('not set')
I get a NameError for "hasattr".
I tried making it
if _.hasattr(self, 'foo'):
return('set')
else:
return('not set')
and that doesn't generate an error, but
it returns "not set".
Any pointers? I'm hoping I'm missing
something simple here.
BTW, I'm using today's CVS (with kludges
to make LoginManager work).
Thank you.
--kyler