[Zope] newbie Q. DTML syntax

Nick Garcia ngarcia@codeit.com
Wed, 31 May 2000 14:22:03 -0700


Brad Moulton wrote:
> 
> As a newbie i have tried a few variations on the following
> but the <dtml-if> never returns true
> 
>  <dtml-in "PARENTS[0].objectValues(['customer'])" sort=lname>
>         <dtml-if "(_['sequence-item'].title == AUTHENTICATED_USER)">
>           <tr><td>customer </td><td><dtml-var accno></td>
>     .......and other values from "customers" folder with meta type customer
> </dtml-if>
> </dtml-in>
> 
> I have previously modified an add_instance method to store
> AUTHENTICATED_USER as the "title"
> viewing the folder shows this to be so.
> If I display these values they appear the same. I just do not know the
> correct syntax inside <dtml-if>

You actually have the syntax correct, you're just comparing apples to
oranges.  AUTHENTICATED_USER is an object, that when called just happens
to return a string.  Your if statement above is comparing the string
attribute title to the object AUTHENTICATED_USER, which is why it's
always returning false.  The correct comparison above would be:

<dtml-if "(_['sequence-item'].title ==
AUTHENTICATED_USER.getUserName())">

The getUserName function of the AUTHENTICATED_USER object returns a
string containing the username.

-- 
Nick Garcia | ngarcia@codeit.com
CodeIt Computing | http://codeit.com