[mod_python] Accesshandler and normal handler... how they working ?

Graham Dumpleton grahamd at dscpl.com.au
Tue Nov 14 16:46:11 EST 2006


durumdara wrote ..
> 1.)
> The access handler is existing in same Thread as Handler ?
> So I want to know. Is modpy do this:
> get url, server info, etc.
> build request + other objects
> get thread
> result = thread.startaccesshandler(req)
> if not result:
>   gotoerrorhandler
> else:
>   result = thread.handler(req)
> ....
> or it use another technology ?

For some background, read:

  http://162.105.203.19/apache-doc/24.htm

This book is about using Perl and C with Apache, but the description
in this section still applies to mod_python.

The introduction and request loop descriptions are most relevant.

> 3.)
> Can I force the access handler to redirect request ?
> Example: the user click on menu that preserved for special users. I
> don't want to redirect to error pages. Can I redirect to my special
> page, or it is useable only in normal handler ?

Just be aware that there is a bug in mod_python 3.2.10 and older where
external redirects are performed from within a handler other than the
response handler phase. See:

  http://issues.apache.org/jira/browse/MODPYTHON-140

You will need to look at how util.redirect() works, do the same thing but
make sure it returns apache.DONE and not apache.OK.

Use of internal redirects is okay if that is appropriate for what you want
to do, noting that after triggering the internal redirect, you again probably
need to return apache.DONE as you don't want later phases to run.

Graham


More information about the Mod_python mailing list