[mod_python] PythonTransHandler contract requirements?

emf i at mindlace.net
Tue Jun 3 14:38:19 EST 2003


Hello,

I'm trying to implement a transhandler, but I cannot figure out what I am 
supposed to provide apache to allow it to continue handling the request. 
Documentation pointers gratefully accepted.

Given a path, I want to provide a handler for the request.

My simplistic translation handler is like so:

def transhandler(req):
    # First check if we're configured to handle this request.
    checkHandle(req)
    root = req.document_root()
    raw_filename = path.join(root,req.uri)
    raw_fileparts = path.split(raw_filename)
    if path.exists(raw_filename):
       if raw_filename[-3:] != '.py':
           raise apache.SERVER_RETURN, apache.DECLINED
       else:
           req.filename=raw_fileparts[0]
           req.modpath=raw_fileparts[0]
           sys.path.append(raw_filename)
           req.add_handler("PythonHandler",raw_fileparts[1][-3:])
           return apache.OK
    raise apache.SERVER_RETURN, apache.DECLINED

And the handler at the location in question:

def handler(req):
    req.write(body % "Ni!")
    return apache.OK

What I get back is the raw text of the module containing the handler.

~mindlace
http://mindlace.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://mailman.modpython.org/pipermail/mod_python/attachments/20030603/ca478f73/attachment-0003.bin


More information about the Mod_python mailing list