1.1 --- a/WebStack/JavaServlet.py Fri Oct 05 22:24:30 2007 +0000
1.2 +++ b/WebStack/JavaServlet.py Fri Oct 05 22:27:28 2007 +0000
1.3 @@ -92,15 +92,16 @@
1.4 Java Servlet transaction interface.
1.5 """
1.6
1.7 - def __init__(self, request, response):
1.8 + def __init__(self, request, response, servlet):
1.9
1.10 """
1.11 Initialise the transaction using the Java Servlet HTTP 'request' and
1.12 - 'response'.
1.13 + 'response', along with the deployment 'servlet'.
1.14 """
1.15
1.16 self.request = request
1.17 self.response = response
1.18 + self.servlet = servlet
1.19 self.status = None
1.20
1.21 # Remember the cookies received in the request.
1.22 @@ -562,8 +563,34 @@
1.23 if session:
1.24 session.invalidate()
1.25
1.26 + # Java-specific variants of the generic methods.
1.27 +
1.28 + def get_attributes(self):
1.29 +
1.30 + """
1.31 + An application-specific method which obtains a dictionary mapping names
1.32 + to attribute values that can be used to store arbitrary information.
1.33 +
1.34 + Since the dictionary of attributes is retained by the transaction during
1.35 + its lifetime, such a dictionary can be used to store information that an
1.36 + application wishes to communicate amongst its components and resources
1.37 + without having to pass objects other than the transaction between them.
1.38 +
1.39 + The returned dictionary can be modified using normal dictionary-like
1.40 + methods. If no attributes existed previously, a new dictionary is
1.41 + created and associated with the transaction.
1.42 + """
1.43 +
1.44 + return Session(self.request)
1.45 +
1.46 # Special Java-specific methods.
1.47
1.48 + def get_servlet(self):
1.49 +
1.50 + "Return the deployment servlet."
1.51 +
1.52 + return self.servlet
1.53 +
1.54 def _get_fields_from_message(self, encoding):
1.55
1.56 "Get fields from a multipart message."
1.57 @@ -641,12 +668,17 @@
1.58
1.59 """
1.60 A simple session class with behaviour more similar to the Python framework
1.61 - session classes.
1.62 + session classes. This class can also be instantiated with a request object
1.63 + and used to access attributes on the request.
1.64 """
1.65
1.66 def __init__(self, session):
1.67
1.68 - "Initialise the session object with the framework 'session' object."
1.69 + """
1.70 + Initialise the session object with the framework 'session' object. If a
1.71 + ServletRequest object is given, the attributes on that will be
1.72 + accessible, as opposed to the attributes on an HttpSession object.
1.73 + """
1.74
1.75 self.session = session
1.76