[Zope] Python Scripts

Peter Bengtsson mail@peterbe.com
Tue, 29 May 2001 10:12:58 +0200


> > What was wrong with
> > if hasattr(context,'coffeebreak'):
> >     print "have coffee"
> > ?
> >
> > This is almost the equivalent of DTML's
> > <dtml-if coffeebreak>
>
> Not really... the DTML equivalent would be:
> <dtml-if "hasattr(context,'coffeebreak')">
> ...which is something quite different ;-)
>
> In a python script, bind the namespace to _ on the bindings tab and then
see
> what happens with:
>
> if _['coffeebreak']:
>   print 'coffee'

The purpose of the Script bit is to check for the presence of an object OR
property, isn't it?

>
> cheers,
>
> Chris
>