[Zope] create Login/Logout functionality

Troy Farrell troy@entheossoft.com
Mon, 05 May 2003 13:30:23 -0500


Entheos Software does zope consulting and custom programming :)

Change the script so it doesn't print anything out like this:
## Script (Python) "authtest"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
request = container.REQUEST
response =  request.RESPONSE

if request.get('AUTHENTICATED_USER').getUserName() == 'Anonymous User':
   response.setStatus('Unauthorized')
   response.setHeader('WWW-Authenticate', 'basic realm="Zope"', 1)

#end script

Then, add this line to your page template:

<span tal:replace="here/authtest" />

or this to a dtml document:

<dtml-call name="authtest">

And try that.

Troy

Andreas Pakulat wrote:
> On 05.Mai 2003 - 18:19:26, Andreas Pakulat wrote:
> 
>>On 05.Mai 2003 - 10:41:11, Troy Farrell wrote:
>>
>>>Using manage_zmi_logout and the zope HelpSys docs, I've come up with 
>>>this script.  Play with it:
>>>
>>>## Script (Python) "authtest"
>>>##bind container=container
>>>##bind context=context
>>>##bind namespace=
>>>##bind script=script
>>>##bind subpath=traverse_subpath
>>>##parameters=
>>>##title=
>>>##
>>>request = container.REQUEST
>>>response =  request.RESPONSE
>>>
>>>response.setHeader('Content-Type','text/html')
>>>
>>>print "<html><head><title>authtest</title><body><p>"
>>>
>>>print "you are " + request['AUTHENTICATED_USER'].getUserName()
>>>
>>>if request.get('AUTHENTICATED_USER').getUserName() == 'Anonymous User':
>>>  print "Trying to authenticate..."
>>>  response.setStatus('Unauthorized')
>>>  response.setHeader('WWW-Authenticate', 'basic realm="Zope"', 1)
>>>
>>>print "</p></body></html>"
>>>return printed
>>>
>>>#end script
>>
>>I'll try that in a minute, but I also found the Product LoginManager.
> 
> 
> Ok, this works nearly perfect. The only thing that doesn't fit my dreams
> is that I cannot directly put the user back on the page he was, I'll
> have to include some link back. That's a bit annoying, but as it also is
> this was within the zmi, I suppose there is no way to do this?!
> 
> Andreas
>