[SPAM] Re: [mod_python] How to get mod_python user to show up in access.log?

Graham Dumpleton grahamd at dscpl.com.au
Wed Aug 17 01:38:26 EDT 2005


Joshua Ginsberg wrote ..
> Just a though -- haven't tested it -- but when your /login script runs,
> can it redirect to http://[email protected]/ instead of 
> http://www.foobar.com/, thus providing an HTTP username?
> 
> -jag
> 
> On Aug 16, 2005, at 5:48 PM, Scott Chapman wrote:
> 
> >> 69.59.200.242 - - [16/Aug/2005:12:20:51 -0700] "POST /login HTTP/1.1"
> >> 302 51
> >> 69.59.200.242 - - [16/Aug/2005:12:20:51 -0700] "GET / HTTP/1.1" 200
> >> 8587
> >
> > The above two lines are in my access.log file.  After the user 
> > successfully logs in, I'd like his userID toshow up here in place of
> > one of the dashes.  Can that be done?  I'm using a custom login page,
> > not the generic version provided by web browsers.

Easier than that, assign the username to "req.user" in your handler once
you have done the authentication.

  def handler(req):
    req.content_type = "text/plain"
    req.send_http_header()
    req.write("mptest.py\n")
    req.user = "hello" 
    return apache.OK

Yields:

  127.0.0.1 - hello [17/Aug/2005:15:35:42 +1000] "GET /~grahamd/handler/mptest.py HTTP/1.1" 200 142

Graham


More information about the Mod_python mailing list