1.1 --- a/WebStack/Adapters/Twisted.py Sun Feb 01 15:28:08 2004 +0000
1.2 +++ b/WebStack/Adapters/Twisted.py Sun Feb 01 15:28:25 2004 +0000
1.3 @@ -5,8 +5,31 @@
1.4 """
1.5
1.6 import WebStack.Twisted
1.7 +import twisted.web.resource
1.8
1.9 -# NOTE: Implement the module code which registers the various components with
1.10 -# NOTE: the framework.
1.11 +class Dispatcher(twisted.web.resource.Resource):
1.12 +
1.13 + "A class dispatching requests to WebStack resources."
1.14 +
1.15 + isLeaf = 1
1.16 +
1.17 + def __init__(self, resource):
1.18 +
1.19 + "Initialise the root application-specific 'resource'."
1.20 +
1.21 + twisted.web.resource.Resource.__init__(self)
1.22 + self.webstack_resource = resource
1.23 +
1.24 + def getChild(self, path, request):
1.25 + raise NotImplementedError, "getChild"
1.26 +
1.27 + def render(self, request):
1.28 +
1.29 + "Dispatch the given 'request' to the root application-specific resource."
1.30 +
1.31 + trans = WebStack.Twisted.Transaction(request)
1.32 + self.webstack_resource.respond(trans)
1.33 + request.finish()
1.34 + return twisted.web.server.NOT_DONE_YET
1.35
1.36 # vim: tabstop=4 expandtab shiftwidth=4