[mod_python] Re: Mod_python 3.1.2b, sethandler + dir listning problem

Gregory (Grisha) Trubetskoy grisha at modpython.org
Tue Jan 13 21:52:38 EST 2004


Sorry for a late response, but this behaviour is (was - fixed in CVS) a
bug. The error message in the log should only show up (and only makes
sense) when you return OK, meaning the user has been authenticated, but
req.user has no value. The bug was that it didn't check for return value,
but always threw an error whenver req.user had no value.

P.S. You have a potential problem lurking in the code below. req.user is
initially None, so instead of:

  if user != "":

use

  if user:

because None is not equal to "" as far as Python is concerned.

Grisha

On Fri, 7 Nov 2003, Stian [iso-8859-1] S?iland wrote:

> We've found out with 3.1.2b that the AuthenHandler-thingie is not fully
> functional.
>
> We tried the simple example from the documentations, and even made it
> simpler:
>
> .htaccess
> ---------
> PythonPath "['/our/libs'] + sys.path"
> PythonAuthenHandler Cerebrum.web.login
> AuthType Basic
> AuthName "Cerebrum"
> require valid-user
>
>
> Cerebrum/web/login.py
> ---------------------
> from mod_python import apache
>
> def authenhandler(req):
>     pw = req.get_basic_auth_pw()
>     user = req.user
>     if user != "":
>         return apache.OK
>     return apache.HTTP_UNAUTHORIZED
>
>
>
> This failed with a 500 Server Error. Watching the apache log reveals a
> hint:
>
> [Fri Nov 07 10:49:42 2003] [error] [client 129.241.56.39]
> python_handler: After PythonAuthenHandler req->user is NULL. Assign
> req.user to avoid this error.
>


More information about the Mod_python mailing list