[mod_python] [Fwd: Defining classes using mod_python]

Luis Sousa llsousa at ualg.pt
Fri Mar 8 11:46:42 EST 2002


But in this way, there's only an handler for that directory, is that 
correct ?
Suppose that I want to have more than one handler in that directory, for 
my organization

Why do you use a virtual host ? That I didn't get it !!!!


Matt H wrote:

>On Fri, 08 Mar 2002 11:19:10 +0000
>"Luis Sousa" <llsousa at ualg.pt> wrote:
>
>>What do you use then ??
>>
>
>something like this :
>--- httpd.conf ----------
><Directory /www/python>
>  AddHandler python-program .py
>  PythonHandler contentAdmin
>  PythonDebug On
></Directory>
>-------------------------
>
>
>
>------- contentAdmin.py -
>
>from mod_python import apache
>from mod_python import util
>
>def handler(request):
>        global req
>        req = request
>        req.content_type = "text/html"
>        req.send_http_header()
>
>        req.write(getTheHTML())
>	
>
>        return apache.OK
>
>-------------------------
>
>I also use this inside a <VirtualHost
>---------httpd.conf----------------
>	<Location /profile>
>                AddHandler python-program .py
>                PythonAuthenHandler authHandler
>                PythonDebug On
>	</Location>
>----------
>
>(Directory is a class of my own)
>
>---- authHandler.py --
>import Directory
>import md5
>
>from mod_python import apache
>from mod_python import util
>
>
>def authenhandler(req):
>        pwd = req.get_basic_auth_pw()
>        usr = req.connection.user
>        if pwd and usr :
>                d = Directory.Directory("/www/Users/" + usr)
>                mdu = d.getLines('md5')
>                if mdu[0][:-1] == md5.new(pwd).hexdigest() :
>                         return apache.OK
>                else :
>                         return apache.HTTP_UNAUTHORIZED
>        return apache.HTTP_UNAUTHORIZED
>
>
>-------------------------
>
>






More information about the Mod_python mailing list