[Zope] problem with dynamic dtml-with
Steffen Hausmann
steffen@hausmann-family.de
Sun, 15 Jun 2003 12:23:03 +0200
On Sun, Jun 15, 2003 at 08:57:30AM +0200, Oliver Bleutgen wrote:
> Steffen Hausmann wrote:
> >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'
Thanks for the hint, I think this is the right direction.
<dtml-with "restrictedTraverse('../../edit/')">
works, but if I try to access the whole path
(../../edit/Terminhinweisverwaltung/) another error is raised.
Error Type: Unauthorized
Error Value: You are not allowed to access Terminhinweisverwaltung in
this context
If I use unrestrictedTraverse it works, but I can't imagine why it
doesn't work if security is turned on.
Any Ideas?
MfG Steffen
--
Zu sagen 'Hier herrscht Freiheit' ist immer ein Irrtum oder auch eine
Lüge -- Freiheit herrscht nicht (Erich Fried)