[Zope] newbie Q. DTML syntax
Brad Moulton
Brad Moulton" <brad@netarchitects.com.au
Fri, 2 Jun 2000 23:27:55 +1000
tried
---------------
<dtml-in "PARENTS[0].objectValues(['job'])" sort=cust>
<dtml-if "_['sequence-item'].title == AUTHENTICATED_USER.getUserName()">
<TR>
<TD rowspan="2" width="16%"><dtml-var
j_number> ---------------------------
and variations
still no joy.....
is the best way to mast the dtml syntax by learning python
I am afraid I feel lost reading the DTML reference
can't when to use what syntax
feel like a moron can't even do a simple if statement
help appreciated
brad
> > 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>
>
> This gets many, many people (including myself). Zope-defined Web request
> variables are usually objects. You are using AUTHENTICATED_USER as if it
was
> a string, which it is not, thus your dtml-if always fails.
>
> To get what you want, use (Zope Quick Reference v. 0.9):
>
> AUTHENTICATED_USER.getUserName()
>
> Something that adds to newbies' confusion on this is that if one writes,
>
> <dtml-var AUTHENTICATED_USER>
>
> one gets the very username that one expects but yet the <dtml-if> still
fails.
> "I can see the freaking name is right!!!! Why are you failing!!???" is the
> expurgated version of what I said when I got bit by this one.
>
> The reason that <dtml-var AUTHENTICATED_USER> renders nicely to the same
> string that AUTHENTICATED_USER.getUserName() does is that
AUTHENTICATED_USER
> is an object of type lib/python/AccesControl/User. This object has the
> getUserName() method but it also has a "__str__" method that Python allows
> to be defined for any class. This "__str__" method is the way that an
object
> should be represented whenever it is printed. In the case of the User
class,
> lib/python/AccessControl/User.py defines the method __str__ as:
>
> def __str__(self): return self.getUserName()
>
> ------------------------------------------------------
> Andres Corrada-Emmanuel Email: andres@corrada.com
> ------------------------------------------------------
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
>