[mod_python] req.user always returns None

Mitesh Shah mshah at harpercollege.edu
Mon Feb 9 18:17:17 EST 2009

I am having some issues trying to req.user to return a username.  I am
very new to python and mod_python.  I happened upon this thread:


http://osdir.com/ml/python.mod_python/2003-10/msg00092.html regarding a
similar issue.


Anyway, even when I ran the code posted by "David Hancock" in the post
above I only got a "None" for the username in the error_log file.  I am
sending this in the URL:



Here is the test setup as it applies to me(basically unchanged).



from mod_python import apache


def handler(req):

        req.content_type = 'text/plain'


        req.write("Hello, world!")

        return apache.OK


def authenhandler(req):

        user = req.user

        pw = req.get_basic_auth_pw()

        req.log_error(str(user) + ' ' + str(pw))

        if user == "fred" and pw == "secret":

                return apache.OK


                return apache.HTTP_UNAUTHORIZED




<Directory "/var/www/html/python">

    AddHandler python-program .py

    PythonHandler mptest

    PythonAuthenHandler mptest

    AuthType Basic

    AuthName "mod_python restricted area"

    require valid-user

    PythonDebug On





[Mon Feb 09 17:10:04 2009] [error] [client] None secret



After attempting to login I get a 401 page and then I am asked to login


Any help would be greatly appreciated!


Thank you,



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20090209/d824ae48/attachment.html

More information about the Mod_python mailing list