1.1 --- a/WebStack/BaseHTTPRequestHandler.py Sat Feb 07 23:56:17 2004 +0000
1.2 +++ b/WebStack/BaseHTTPRequestHandler.py Sun Feb 08 16:34:11 2004 +0000
1.3 @@ -150,6 +150,24 @@
1.4
1.5 return self.content
1.6
1.7 + def get_response_code(self):
1.8 +
1.9 + """
1.10 + Get the response code associated with the transaction. If no response
1.11 + code is defined, None is returned.
1.12 + """
1.13 +
1.14 + return self.response_code
1.15 +
1.16 + def set_response_code(self, response_code):
1.17 +
1.18 + """
1.19 + Set the 'response_code' using a numeric constant defined in the HTTP
1.20 + specification.
1.21 + """
1.22 +
1.23 + self.response_code = response_code
1.24 +
1.25 def set_content_type(self, content_type):
1.26
1.27 """
2.1 --- a/WebStack/Generic.py Sat Feb 07 23:56:17 2004 +0000
2.2 +++ b/WebStack/Generic.py Sun Feb 08 16:34:11 2004 +0000
2.3 @@ -194,6 +194,24 @@
2.4
2.5 raise NotImplementedError, "get_response_stream"
2.6
2.7 + def get_response_code(self):
2.8 +
2.9 + """
2.10 + Get the response code associated with the transaction. If no response
2.11 + code is defined, None is returned.
2.12 + """
2.13 +
2.14 + raise NotImplementedError, "get_response_code"
2.15 +
2.16 + def set_response_code(self, response_code):
2.17 +
2.18 + """
2.19 + Set the 'response_code' using a numeric constant defined in the HTTP
2.20 + specification.
2.21 + """
2.22 +
2.23 + raise NotImplementedError, "set_response_code"
2.24 +
2.25 def set_content_type(self, content_type):
2.26
2.27 """
3.1 --- a/WebStack/ModPython.py Sat Feb 07 23:56:17 2004 +0000
3.2 +++ b/WebStack/ModPython.py Sun Feb 08 16:34:11 2004 +0000
3.3 @@ -6,6 +6,7 @@
3.4
3.5 import Generic
3.6 from mod_python.util import FieldStorage
3.7 +from mod_python import apache
3.8
3.9 class Transaction(Generic.Transaction):
3.10
3.11 @@ -18,6 +19,7 @@
3.12 "Initialise the transaction using the mod_python transaction 'trans'."
3.13
3.14 self.trans = trans
3.15 + self.response_code = apache.OK
3.16
3.17 # Request-related methods.
3.18
3.19 @@ -122,6 +124,24 @@
3.20
3.21 return self.trans
3.22
3.23 + def get_response_code(self):
3.24 +
3.25 + """
3.26 + Get the response code associated with the transaction. If no response
3.27 + code is defined, None is returned.
3.28 + """
3.29 +
3.30 + return self.response_code
3.31 +
3.32 + def set_response_code(self, response_code):
3.33 +
3.34 + """
3.35 + Set the 'response_code' using a numeric constant defined in the HTTP
3.36 + specification.
3.37 + """
3.38 +
3.39 + self.response_code = response_code
3.40 +
3.41 def set_content_type(self, content_type):
3.42
3.43 """
4.1 --- a/WebStack/Twisted.py Sat Feb 07 23:56:17 2004 +0000
4.2 +++ b/WebStack/Twisted.py Sun Feb 08 16:34:11 2004 +0000
4.3 @@ -127,6 +127,26 @@
4.4
4.5 return self.trans
4.6
4.7 + def get_response_code(self):
4.8 +
4.9 + """
4.10 + Get the response code associated with the transaction. If no response
4.11 + code is defined, None is returned.
4.12 + """
4.13 +
4.14 + # NOTE: Accessing the request attribute directly.
4.15 +
4.16 + return self.trans.code
4.17 +
4.18 + def set_response_code(self, response_code):
4.19 +
4.20 + """
4.21 + Set the 'response_code' using a numeric constant defined in the HTTP
4.22 + specification.
4.23 + """
4.24 +
4.25 + self.trans.setResponseCode(response_code)
4.26 +
4.27 def set_content_type(self, content_type):
4.28
4.29 """
5.1 --- a/WebStack/Webware.py Sat Feb 07 23:56:17 2004 +0000
5.2 +++ b/WebStack/Webware.py Sun Feb 08 16:34:11 2004 +0000
5.3 @@ -132,6 +132,33 @@
5.4
5.5 return self.trans.response()
5.6
5.7 + def get_response_code(self):
5.8 +
5.9 + """
5.10 + Get the response code associated with the transaction. If no response
5.11 + code is defined, None is returned.
5.12 + """
5.13 +
5.14 + # NOTE: Webware treats the response code as just another header.
5.15 +
5.16 + status = self.trans.response().header("Status", None)
5.17 + try:
5.18 + if status is not None:
5.19 + return int(status)
5.20 + else:
5.21 + return None
5.22 + except ValueError:
5.23 + return None
5.24 +
5.25 + def set_response_code(self, response_code):
5.26 +
5.27 + """
5.28 + Set the 'response_code' using a numeric constant defined in the HTTP
5.29 + specification.
5.30 + """
5.31 +
5.32 + self.trans.response().setStatus(response_code)
5.33 +
5.34 def set_content_type(self, content_type):
5.35
5.36 """