1.1 --- a/WebStack/Adapters/Webware.py Sat Feb 07 23:37:17 2004 +0000
1.2 +++ b/WebStack/Adapters/Webware.py Sat Feb 07 23:38:00 2004 +0000
1.3 @@ -6,8 +6,53 @@
1.4
1.5 import WebStack.Webware
1.6
1.7 -# NOTE: Webware Experimental seems to employ special URLParsers in contexts
1.8 -# NOTE: which are much more compatible with the WebStack approach.
1.9 +# For Webware releases later than 0.8.1, employ special URLParsers in contexts
1.10 +# for each application in the application server; such parsers create servlets
1.11 +# instead of having servlet factories do that work.
1.12 +
1.13 +try:
1.14 + from WebKit.URLParser import URLParser
1.15 +
1.16 +except ImportError:
1.17 +
1.18 + # NOTE: Using Webware 0.8.1 or earlier. Assume that this really is the case.
1.19 +
1.20 + pass
1.21 +
1.22 +else:
1.23 + class WebStackURLParser(URLParser):
1.24 +
1.25 + """
1.26 + A custom URL parser which provides access to application-specific resources.
1.27 + Override the 'parse' method for more precise control of servlet
1.28 + instantiation.
1.29 + """
1.30 +
1.31 + def __init__(self, resource):
1.32 +
1.33 + """
1.34 + Initialise the parser object with the given root application-specific
1.35 + 'resource'.
1.36 + """
1.37 +
1.38 + self.webstack_resource = resource
1.39 +
1.40 + def parse(self, trans, requestPath):
1.41 +
1.42 + """
1.43 + For the given Webware transaction, 'trans', override the usual servlet
1.44 + factory mechanism and return a servlet which will provide access to the
1.45 + application-specific resources.
1.46 + The 'trans' object - a Webware transaction - is not given to the servlet
1.47 + since such information is available when the 'respond' method is invoked
1.48 + on the servlet.
1.49 + The provided 'requestPath' object is not used, since this information
1.50 + should be available elsewhere.
1.51 + """
1.52 +
1.53 + return WebStackServlet(self.webstack_resource)
1.54 +
1.55 +# For Webware 0.8.1 and earlier, employ servlet factories and servlets.
1.56
1.57 from WebKit.ServletFactory import ServletFactory
1.58 from WebKit.Servlet import Servlet
1.59 @@ -58,6 +103,8 @@
1.60
1.61 return WebStackServlet(self.webstack_resource)
1.62
1.63 +# Servlets are common to both solutions.
1.64 +
1.65 class WebStackServlet(Servlet):
1.66
1.67 "A servlet which dispatches transactions to application-specific resources."
1.68 @@ -66,6 +113,7 @@
1.69
1.70 "Initialise the servlet with an application-specific 'resource'."
1.71
1.72 + Servlet.__init__(self)
1.73 self.webstack_resource = resource
1.74
1.75 def respond(self, trans):