1.1 --- a/WebStack/Adapters/ModPython.py Sun Feb 01 15:28:08 2004 +0000
1.2 +++ b/WebStack/Adapters/ModPython.py Sun Feb 01 15:28:25 2004 +0000
1.3 @@ -5,8 +5,23 @@
1.4 """
1.5
1.6 import WebStack.ModPython
1.7 +from mod_python import apache
1.8
1.9 -# NOTE: Implement a handler function which converts a request to a transaction
1.10 -# NOTE: and invokes application resources.
1.11 +def dispatch(request, resource):
1.12 +
1.13 + "Dispatch the given 'request' to the root application-specific 'resource'."
1.14 +
1.15 + trans = WebStack.ModPython.Transaction(request)
1.16 + try:
1.17 + # NOTE: Resource pooling may be appropriate.
1.18 +
1.19 + resource.respond(trans)
1.20 + return apache.OK
1.21 + except:
1.22 +
1.23 + # NOTE: Error conditions should be investigated further, along with
1.24 + # NOTE: other response states.
1.25 +
1.26 + return apache.INTERNAL_SERVER_ERROR
1.27
1.28 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/WebStack/Adapters/Twisted.py Sun Feb 01 15:28:08 2004 +0000
2.2 +++ b/WebStack/Adapters/Twisted.py Sun Feb 01 15:28:25 2004 +0000
2.3 @@ -5,8 +5,31 @@
2.4 """
2.5
2.6 import WebStack.Twisted
2.7 +import twisted.web.resource
2.8
2.9 -# NOTE: Implement the module code which registers the various components with
2.10 -# NOTE: the framework.
2.11 +class Dispatcher(twisted.web.resource.Resource):
2.12 +
2.13 + "A class dispatching requests to WebStack resources."
2.14 +
2.15 + isLeaf = 1
2.16 +
2.17 + def __init__(self, resource):
2.18 +
2.19 + "Initialise the root application-specific 'resource'."
2.20 +
2.21 + twisted.web.resource.Resource.__init__(self)
2.22 + self.webstack_resource = resource
2.23 +
2.24 + def getChild(self, path, request):
2.25 + raise NotImplementedError, "getChild"
2.26 +
2.27 + def render(self, request):
2.28 +
2.29 + "Dispatch the given 'request' to the root application-specific resource."
2.30 +
2.31 + trans = WebStack.Twisted.Transaction(request)
2.32 + self.webstack_resource.respond(trans)
2.33 + request.finish()
2.34 + return twisted.web.server.NOT_DONE_YET
2.35
2.36 # vim: tabstop=4 expandtab shiftwidth=4