[mod_python] req.user always returns None?

Gregory (Grisha) Trubetskoy grisha at modpython.org
Sun Oct 19 23:21:00 EST 2003



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


More information about the Mod_python mailing list