[mod_python] Complicated GET configuration

Hunter Matthews thm at duke.edu
Fri Aug 16 17:05:28 EST 2002


On Fri, 2002-08-16 at 16:40, Hunter Matthews wrote:
> On Fri, 2002-08-16 at 16:27, Ian Clelland wrote:
> 
> > Because of the <Location> directive, Apache will hand all requests for 
> > /XMLRPC and any URL below that to your python module. If you don't want 
> > mod_python to handle the GET requests underneath /XMLRPC, then your 
> > handler should return apache.DECLINED if req.uri != '/XMLRPC'.
> 
> I switched to <Location ~ "/XMLRPC$">
> 
> So right now my apache config looks like: 
> 
> Alias /XMLRPC/$RHN/ /local/linux/current/www/
> 
> <Directory /local/linux>
>     # I realize that the default config is to have symlinks on, but the 
>     # current part should stand on its own.
>     Options FollowSymLinks
>     AllowOverride None
> </Directory>
> 
> <Location ~ "/XMLRPC$">
>     PythonPath "sys.path+['/usr/share/current']"
>     SetHandler python-program
>     PythonHandler current_apache
> </Location>
> 
> <Location /XMLRPC/$RHN>
>     PythonPath "sys.path+['/usr/share/current']"
>     PythonAuthzHandler current_apache
> </Location>
> 
> 
> 
> > 
> > Also, as far as I understand it, the SetHandler directive shouldn't be 
> > required in order to invoke a PythonAuthzHandler, but I could be wrong. 
> > (Not that it will make a difference in your case; the SetHandler for 
> > /XMLRPC will also affect the /XMLRPC/$RHN subdirectory anyway)
> 
> That would be ideal. However, with the following code in 
> /usr/share/current/current_apache.py:
> 
> def authzhandler(req):
>     """ temp function for testing"""
> 
>     apache.log_error("Inside the authzhandler!")
>     apache.log_error("method = %s" % req.method)
>     apache.log_error("headers = %s" % pprint.pprint(req.headers_in))
> 
>     return apache.OK
> 
> 
> After an apache restart (to make sure all the updated modules get
> reloaded) I'm not seeing any of those log_errors in the error file.
> Once I see something (anything) I'll replace that code with the real
> thing.
> 
> I appreciate the help from the list.

Sorry to spam the list so hard today, but I've figured one piece of it
out:

def authzhandler(req):
    """ temp function for testing"""
 
    apache.log_error("Inside the authzhandler!")
    apache.log_error("method = %s" % req.method)
    apache.log_error("headers = %s" % pprint.pprint(req.headers_in))

    return apache.OK

This code still results in nothing in my logs. On the theory that
perhaps it was undocumented for a reason, I tried a different (nearly
random) handler:


def headerparserhandler(req):
    """ temp function for testing"""

    apache.log_error("Inside the headerparserhandler!")
    apache.log_error("method = %s" % req.method)
#    apache.log_error("headers = %s" % pprint.pprint(req.headers_in))
    for key in req.headers_in.keys():
        apache.log_error("hdr[%s] = %s" % (key, req.headers_in[key]))
    return apache.HTTP_UNAUTHORIZED                      

AND THIS WORKS JUST FINE!

If anyone on the list has any ideas why the authz handler, which
_looked_ like the handler I should use (using HTTP request headers to
determine if a client was authorized to make this request), isn't
working, I'd still appreciate knowing. 

However, I should be able to use this handler or maybe even
PythonAuthenHandler, so its not a critical issue for me now.

THanks everyone.

-- 
Hunter Matthews                          Unix / Network Administrator
Office: BioScience 145/244               Duke Univ. Biology Department
Key: F0F88438 / FFB5 34C0 B350 99A4 BB02  9779 A5DB 8B09 F0F8 8438
Never take candy from strangers. Especially on the internet.




More information about the Mod_python mailing list