On Monday 29 October 2001 08:26 am, Mitch Model allegedly wrote:
What's wrong with the 'getattr' call in this DTML method? I get an error message: "Name not found or not allowed undefined." (using ZDebug). (The problem is not the choice of attribute names -- I get it whatever I type that isn't an attribute in the REQUEST.) If I arrange to get into pdb from this method, the getattr expression works fine. Is this a Zope bug?
_____________________________________________________________________ <html> <body> REQUEST does <dtml-if expr="not _.hasattr(REQUEST,'undefined')"> not </dtml-if> have the attribute 'undefined'. <p> value = <dtml-var expr="_.getattr(REQUEST, 'undefined', 'nothing')"> </body> </html> _____________________________________________________________________
Calling hasattr on REQUEST is not allowed from DTML, and is not necessary. Try using has_key instead, as in: <dtml-if expr="REQUEST.has_key('whatever')"> To get the desired default value behavior, user REQUEST.get: value = <dtml-var expr="REQUEST.get('somevar', 'nothing')"> hth, /---------------------------------------------------\ Casey Duncan, Sr. Web Developer National Legal Aid and Defender Association c.duncan@nlada.org \---------------------------------------------------/