1.1 --- a/WebStack/Adapters/CGI.py Sun Jan 15 23:18:29 2006 +0000
1.2 +++ b/WebStack/Adapters/CGI.py Sun Jan 15 23:20:27 2006 +0000
1.3 @@ -24,7 +24,8 @@
1.4 from WebStack.Generic import EndOfResponse
1.5 import sys, os
1.6
1.7 -def deploy(resource, authenticator=None, input=None, output=None, env=None, handle_errors=1):
1.8 +def deploy(resource, authenticator=None, input=None, output=None, env=None,
1.9 + address=None, handle_errors=1):
1.10
1.11 """
1.12 Dispatch to the root application-specific 'resource'. Employ the optional
1.13 @@ -34,6 +35,8 @@
1.14 environment respectively. Note that 'env' must evaluate to true for it to
1.15 replace the default. The optional 'handle_errors' parameter (if true) causes
1.16 handlers to deal with uncaught exceptions cleanly.
1.17 +
1.18 + The optional 'address' parameter is deliberately ignored.
1.19 """
1.20
1.21 trans = WebStack.CGI.Transaction(input or sys.stdin, output or sys.stdout,
2.1 --- a/WebStack/Adapters/Django.py Sun Jan 15 23:18:29 2006 +0000
2.2 +++ b/WebStack/Adapters/Django.py Sun Jan 15 23:20:27 2006 +0000
2.3 @@ -23,16 +23,36 @@
2.4 import WebStack.Django
2.5 from WebStack.Generic import EndOfResponse
2.6
2.7 -def respond(request, resource, authenticator=None, handle_errors=1):
2.8 +def deploy(resource, authenticator=None, address=None, handle_errors=1):
2.9 +
2.10 + """
2.11 + Deploy the given 'resource', employing the optional 'authenticator' to
2.12 + protect it. The optional 'handle_errors' parameter (if true) causes handlers
2.13 + to deal with uncaught exceptions cleanly.
2.14 +
2.15 + The optional 'address' parameter is deliberately ignored.
2.16 + """
2.17 +
2.18 + def _deploy(request, *args, **kw):
2.19 + return respond(request, resource, authenticator=authenticator,
2.20 + virtual_path_info=kw.get("vp"), handle_errors=handle_errors)
2.21 + return _deploy
2.22 +
2.23 +def respond(request, resource, authenticator=None, virtual_path_info=None, handle_errors=1):
2.24
2.25 """
2.26 Dispatch to the root application-specific 'resource'. Employ the optional
2.27 - 'authenticator' to control access to the resource. The optional
2.28 - 'handle_errors' parameter (if true) causes handlers to deal with uncaught
2.29 - exceptions cleanly.
2.30 + 'authenticator' to control access to the resource. Define the optional
2.31 + 'virtual_path_info' as the path information considered to belong to the
2.32 + given 'resource'.
2.33 +
2.34 + The optional 'handle_errors' parameter (if true) causes handlers to deal
2.35 + with uncaught exceptions cleanly.
2.36 """
2.37
2.38 trans = WebStack.Django.Transaction(request)
2.39 + if virtual_path_info:
2.40 + trans.set_virtual_path_info(virtual_path_info)
2.41
2.42 try:
2.43 if authenticator is None or authenticator.authenticate(trans):
3.1 --- a/WebStack/Adapters/JavaServlet.py Sun Jan 15 23:18:29 2006 +0000
3.2 +++ b/WebStack/Adapters/JavaServlet.py Sun Jan 15 23:20:27 2006 +0000
3.3 @@ -22,6 +22,35 @@
3.4
3.5 import WebStack.JavaServlet
3.6 from WebStack.Generic import EndOfResponse
3.7 +from javax.servlet.http import HttpServlet
3.8 +
3.9 +def deploy(resource, authenticator=None, address=None, handle_errors=1):
3.10 +
3.11 + """
3.12 + Deploy the given 'resource' and optional 'authenticator'.
3.13 + The optional 'handle_errors' flag, if set to false, causes tracebacks to be
3.14 + displayed in the browser.
3.15 +
3.16 + The optional 'address' parameter is deliberately ignored.
3.17 + """
3.18 +
3.19 + # NOTE: Since jython 2.1 does not support the nested scope mechanisms
3.20 + # NOTE: required to just drop the above parameters into methods even as
3.21 + # NOTE: default parameters, we employ class attributes.
3.22 +
3.23 + class _Deploy(HttpServlet):
3.24 + def __init__(self):
3.25 + HttpServlet.__init__(self)
3.26 + self.dispatcher = Dispatcher(self.resource, self.authenticator, self.handle_errors)
3.27 +
3.28 + def service(self, request, response):
3.29 + self.dispatcher.service(request, response)
3.30 +
3.31 + _Deploy.resource = resource
3.32 + _Deploy.authenticator = authenticator
3.33 + _Deploy.handle_errors = handle_errors
3.34 +
3.35 + return _Deploy
3.36
3.37 class Dispatcher:
3.38
4.1 --- a/WebStack/Adapters/ModPython.py Sun Jan 15 23:18:29 2006 +0000
4.2 +++ b/WebStack/Adapters/ModPython.py Sun Jan 15 23:20:27 2006 +0000
4.3 @@ -24,6 +24,22 @@
4.4 from WebStack.Generic import EndOfResponse
4.5 from mod_python import apache
4.6
4.7 +def deploy(resource, authenticator=None, address=None, handle_errors=1):
4.8 +
4.9 + """
4.10 + Deploy the given 'resource' and optional 'authenticator'.
4.11 + The optional 'handle_errors' flag, if set to false, causes tracebacks to be
4.12 + displayed in the browser.
4.13 +
4.14 + The optional 'address' parameter is deliberately ignored.
4.15 + """
4.16 +
4.17 + def _respond(request):
4.18 + return respond(request, resource, handle_errors=handle_errors)
4.19 + def _authenticate(request):
4.20 + return authenticate(request, authenticator, handle_errors=handle_errors)
4.21 + return _respond, _authenticate
4.22 +
4.23 def respond(request, resource, handle_errors=1):
4.24
4.25 """
5.1 --- a/WebStack/Adapters/Webware.py Sun Jan 15 23:18:29 2006 +0000
5.2 +++ b/WebStack/Adapters/Webware.py Sun Jan 15 23:20:27 2006 +0000
5.3 @@ -74,6 +74,11 @@
5.4 return WebStackServlet(self.webstack_resource, self.webstack_authenticator,
5.5 self.handle_errors)
5.6
5.7 + # Convenience function.
5.8 +
5.9 + def deploy(resource, authenticator=None, address=None, handle_errors=1):
5.10 + return WebStackURLParser(resource, authenticator=authenticator, handle_errors=handle_errors)
5.11 +
5.12 # For Webware 0.8.1 and earlier, employ servlet factories and servlets.
5.13
5.14 from WebKit.ServletFactory import ServletFactory