[Zope] Checking for authenticated users...

Cornelis J. de Brabander brabander@fsw.LeidenUniv.nl
Mon, 02 Apr 2001 10:29:40 +0200


hi
> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
> Ixokai
> Sent: maandag 2 april 2001 10:19
> To: zope@zope.org
> Subject: [Zope] Checking for authenticated users...
>
>
> I'm in the process of working with Zope for the first time as a learning
> exercise.. So far, I'm rather impressed with the immense
> potential of what I
> can see myself doing without a great deal of difficulty.
>
> The 'skeleton' index_html in / that provides a standard look for
> everything,
> and so on, and so forth... Its just nice.
>
> Now i'm working on my first form, and am having just a bit of trouble.
> Perhaps its because I've never ended up using .real. HTTP
> authentication in
> any other website I've done :)
>
> I want the form to insert the person's username into the form if they have
> logged in, otherwise, not enter anything and just print
> "Unregistered User"
> on the webpage.
>
> Here's what I'm trying, which simply isn't working :) It prints 'Anonymous
> User' instead of 'Unregistered User' if my user isn't logging in.
>
> <dtml-if expr="AUTHENTICATED_USER != 'Anonymous User'">

AUTHENTICATED_USER is an object. So you are trying to compare the instance
of an object with a string. The AUTHENTICATED_USER object has a method
called getUserName that returns the name as a string:

<dtml-if expr="AUTHENTICATED_USER.getUserName() != 'Anonymous User'">

>    <input type="text" name="From" value="&dtml-AUTHENTICATED_USER;"
> size="36" maxlength="36">
>   <dtml-else>
>    Unregistered User
>   </dtml-if>
>
> What am I doing wrong?
>
> Thanks for your help. :)
>
> --Ix
>

cb