[Zope] Re: login page problem

Cliff Ford Cliff.Ford at ed.ac.uk
Sun Apr 3 04:39:01 EDT 2005


I have been trying to think of ways of providing specific pointers, So, 
assuming you have a custom login page and a custom python script that 
processes that page:

In the Python script you could set a cookie for the District:

context.REQUEST.RESPONSE.setCookie('District', district)

where district is the name of the District field in the form. The 
District parameter is then always available to your page templates and 
scripts in the REQUEST object.

At the end of your login script you would typically redirect to some 
specific page like this:

return context.REQUEST.RESPONSE.redirect('aURL')

in exUserFolder you don't have to do anything else - the login works by 
magic, which is very confusing.

Now for the problems:

If the login is wrong the system will call /standard_error_message, so 
you have to customise that to send the user back to the login form with 
a Login failed message.

If the user bookmarks a protected page and tries to jump to it without 
being logged in, the system will call the login sequence starting in 
acl_users, so you have to customise that to call your own login page.

After the user has logged in, whenever you need to get the Username you 
would typically use a python script like this:

from AccessControl import getSecurityManager
return getSecurityManager().getUser().getUserName()

HTH

Cliff


prabuddha ray wrote:
> Its been very kind of u all to be critical  about a newbie like me.
> I'll definitely lookout for those ettiquetes.
> 
> My python script error got solved as i missed the silly ' ' in the
> response.redirect statemnet.
> I set the user and pwd request vars in sesson var.
> 
> Tried cookie crumbler and MysqlUserFolder and UserFolder also but they
> all need to changed much and my requirements are diffrent.
> 
> I'm building a trial govt. site for stores management which was built
> previously in ASP.
> The login page takes the districtname , username and passwd .
> according to the type of user different menus are displayed.
> 
> For this i need to have the  districtname , username and passwd 
> carried on throughout the session.
> 
> my current requirement is to pass the session vars through the python
> script which is the action of the login form.
> 
> I've gone through the zopebook but dint find much help there.
> 
> can u plz tell me where do i get to know about pythopn scripting done
> in zope n ZPT examples.
> 
> i'm really sorry for my erronous language. please dont overlook theese
> humble requests.
> 
> On Fri, 1 Apr 2005 23:07:38 +0200, Dieter Maurer <dieter at handshake.de> wrote:
> 
>>prabuddha ray wrote at 2005-3-30 23:50 -0800:
>>
>>>...
>>>now my problem how n where do i check d pwd n redirect to the next zpt
>>>or the previous one if its wrong.
>>
>>Apparently, you need some background reading...
>>
>>Especially, you need to understand that HTTP is a stateless
>>protocol and *EACH* request must somehow perform its own
>>authentication. That's why usually login information is
>>(somehow) coded in a cookie.
>>
>>You really should follow the advice to look at an existing
>>UserFolder (they are responsible for authentication).
>>You may need to adapt/extend an existing UserFolder.
>>
>>
>>-- 
>>Dieter
>>
> 
> 


More information about the Zope mailing list