[Zope] <dtml-var xxx> in a python script

Evan Simpson evan@4-am.com
Wed, 15 Aug 2001 00:14:07 -0400


> > How can I get the equivalent of <dtml-var xxx> in a python script,
using
> > acquisition.
>
> context.xxx or context.xxx(), depending on xxx.

The problem with trying to translate DTML to Python is that <dtml-var
xxx> incorporates a lot of magical behaviour.  Apart from rendering the
object (calling it if it is callable), as implied by the ()-or-no-()
above, the name 'xxx' could be found in many places.  Here's a sampling
of ways to access an object 'xxx' in a Script:

1. From the target of the Script, or its context:
    context.xxx
    getattr(context, 'xxx')

2. From the Script's container, regardless of context:
    container.xxx
    getattr(container, 'xxx')

3. From a submitted form, cookies, URL query, or REQUEST.set() call:
    context.REQUEST['xxx']
    context.REQUEST.form['xxx']
    context.REQUEST.cookies['xxx']
    context.REQUEST.other['xxx']

Cheers,

Evan @ Zope