[Zope] problem with dynamic dtml-with
Oliver Bleutgen
myzope@gmx.net
Sun, 15 Jun 2003 08:57:30 +0200
Steffen Hausmann wrote:
> Hi,
>
> I'm using the following dtml-with expression and it works perfekt.
>
> <dtml-with "aq_parent.aq_parent.edit.Terminhinweisverwaltung">
> <dtml-var index_html>
> </dtml-with>
>
> As it can't be static anymore it tried the following.
>
> <dtml-call "REQUEST.set('wusch', 'aq_parent.aq_parent.edit.Terminhinweisverwaltung')">
>
> <dtml-with "_[wusch]">
> <dtml-var index_html>
> </dtml-with>
>
> But this raises an KeyError.
>
> Error Type: KeyError
> Error Value: aq_parent.aq_parent.edit.Terminhinweisverwaltung
>
> If the value of wusch is 'aq_parent' it works, but as soon as there is
> a dot in it another KeyError is raised.
>
> Any ideas what I'm doing wrong?
Yeah, you're either misunderstanding the meaning of _[...], or the
meaning of the dot in python expressions.
_['string'] tries to find the value of the variable named string in the
namespace.
The dot is an operator which means basically "lookup".
So "a.b.c.d" is a python expression, no variable name, and _[...] can't
work.
May it might be better to use restrictedTraverse()?
Or <dtml-with "aq_parent.aq_parent.edit[wusch]">, where e.g.
wusch == 'Terminverwaltung'
HTH,
oliver