1.1 --- a/WebStack/Webware.py Thu Sep 27 22:50:56 2007 +0000
1.2 +++ b/WebStack/Webware.py Fri Sep 28 22:59:43 2007 +0000
1.3 @@ -40,6 +40,12 @@
1.4 self.trans = trans
1.5 self.content_type = None
1.6
1.7 + def commit(self):
1.8 +
1.9 + "Commit the transaction."
1.10 +
1.11 + self.trans.response().commit()
1.12 +
1.13 # Server-related methods.
1.14
1.15 def get_server_name(self):
1.16 @@ -128,25 +134,38 @@
1.17 charset employed.
1.18 """
1.19
1.20 - return self.parse_content_type(self.trans.request().contentType())
1.21 + request = self.trans.request()
1.22 + if hasattr(request, "contentType"):
1.23 + content_type = request.contentType()
1.24 + else:
1.25 + content_type = self.trans.request()._environ.get('CONTENT_TYPE', None)
1.26 + return self.parse_content_type(content_type)
1.27
1.28 def get_content_charsets(self):
1.29
1.30 """
1.31 Returns the character set preferences.
1.32 - NOTE: Requires enhancements to HTTPRequest.
1.33 + NOTE: Requires enhancements to HTTPRequest in 0.8.1 or earlier.
1.34 """
1.35
1.36 - return self.trans.request().contentCharsets()
1.37 + request = self.trans.request()
1.38 + if hasattr(request, "contentCharsets"):
1.39 + return request.contentCharsets()
1.40 + else:
1.41 + return request.accept("charset")
1.42
1.43 def get_content_languages(self):
1.44
1.45 """
1.46 Returns extracted language information from the transaction.
1.47 - NOTE: Requires enhancements to HTTPRequest.
1.48 + NOTE: Requires enhancements to HTTPRequest in 0.8.1 or earlier.
1.49 """
1.50
1.51 - return self.trans.request().contentLanguages()
1.52 + request = self.trans.request()
1.53 + if hasattr(request, "contentLanguages"):
1.54 + return request.contentLanguages()
1.55 + else:
1.56 + return request.accept("language")
1.57
1.58 def get_path(self, encoding=None):
1.59
1.60 @@ -199,10 +218,20 @@
1.61
1.62 path_info = self.trans.request().pathInfo()
1.63 context_name = self.trans.request().contextName()
1.64 +
1.65 + # Make the context name resemble the start of a path if it doesn't
1.66 + # already do so.
1.67 +
1.68 + if not context_name.startswith("/"):
1.69 + context_name = "/" + context_name
1.70 +
1.71 + # Correct the path info if appropriate.
1.72 +
1.73 if path_info.startswith(context_name):
1.74 real_path_info = path_info[len(context_name):]
1.75 else:
1.76 real_path_info = path_info
1.77 +
1.78 return decode_value(real_path_info, encoding)
1.79
1.80 def get_query_string(self):
1.81 @@ -392,7 +421,7 @@
1.82 specification.
1.83 """
1.84
1.85 - self.trans.response().setStatus(response_code)
1.86 + self.trans.response().setStatus(response_code, str(response_code))
1.87
1.88 def set_header_value(self, header, value):
1.89