[mod_python] req.user always returns None?

Michael C. Neel neel at mediapulse.com
Mon Oct 20 10:25:12 EST 2003


Would it make since to add a function req.get_basic_auth() that returns
a tuple of (username, passwd)?  For backwards compatibility a call to
get_basic_auth_pw() followed by getting the req.user could remain, but:

user, pw = req.get_basic_auth()

might be easier to follow and be gentler on new users

Mike


> -----Original Message-----
> From: Gregory (Grisha) Trubetskoy [mailto:grisha at modpython.org] 
> Sent: Sunday, October 19, 2003 11:21 PM
> To: Hancock, David (DHANCOCK)
> Cc: 'mod_python at modpython.org'
> Subject: Re: [mod_python] req.user always returns None?
> 
> 
> 
> 
> On Sun, 19 Oct 2003, Hancock, David (DHANCOCK) wrote:
> 
> > def authenhandler(req):
> >     user = req.user
> >     pw = req.get_basic_auth_pw()
> >     req.log_error(str(user) + ' ' + str(pw))
> >     if user == "david" and pw == "secret":
> >         return apache.OK
> >     else:
> >         return apache.HTTP_UNAUTHORIZED
> 
> The current docs neglect to mention this because at the time it seemed
> like it was no longer necessary, but the call to get_basic_auth_pw()
> should always _preceed_ the use of req.user. If the swap the first two
> lines, it will work (regardless of position of LoadModule within the
> config file).
> 
> Grisha
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
> 



More information about the Mod_python mailing list