[Zope] comparing variables ??
Greg Ward
gward@cnri.reston.va.us
Tue, 14 Dec 1999 11:11:16 -0500
> >>> "Geir B Hansen" wrote
> > i try to compare two variables to check if they are equal, like this :
> >
> > <dtml-if expr="PARENTS[0].id == AUTHENTICATED_USER">
> > <h2>YES !!</h2>
> > <dtml-else>
> > <h2>NO</h2>
> > </dtml-if>
>
On 14 December 1999, Anthony Baxter said:
> AUTHENTICATED_USER isn't actually a string - it's an object, which
> has a string representation that _looks_ like a string.
>
> AUTHENTICATED_USER.getUserName() is what you're looking for here.
Or, if you don't happen to know the name of the method, you can just use
the standard Python function for getting an object's string
representation. In straight Python, this would be
str (AUTHENTICATED_USER)
but in DTML's bastard offshoot of Python, it's
_.str (AUTHENTICATED_USER)
so this just might work:
<dtml-if expr="PARENTS[0].id == _.str(AUTHENTICATED_USER)">
although if you want to be really safe, I guess you'd do this:
<dtml-if expr="_.str(PARENTS[0].id) == _.str(AUTHENTICATED_USER)">
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913