1 #!/usr/bin/env python 2 3 """ 4 mod_python adapter. 5 """ 6 7 import WebStack.ModPython 8 from mod_python import apache 9 10 def dispatch(request, resource, debug=0): 11 12 """ 13 Dispatch the given 'request' to the root application-specific 'resource'. 14 The optional 'debug' flag, if set to 1, causes tracebacks to be displayed in 15 the browser. 16 """ 17 18 trans = WebStack.ModPython.Transaction(request) 19 20 # NOTE: Resource pooling may be appropriate. 21 22 try: 23 resource.respond(trans) 24 return apache.OK 25 except: 26 27 # NOTE: Error conditions should be investigated further, along with 28 # NOTE: other response states. 29 30 if not debug: 31 return apache.HTTP_INTERNAL_SERVER_ERROR 32 else: 33 raise 34 35 # vim: tabstop=4 expandtab shiftwidth=4