1.1 --- a/WebStack/Zope.py Thu Aug 26 23:12:57 2004 +0000
1.2 +++ b/WebStack/Zope.py Fri Aug 27 17:37:39 2004 +0000
1.3 @@ -9,6 +9,7 @@
1.4 import Generic
1.5 from Helpers import Environment
1.6 from Helpers.Request import Cookie
1.7 +from Helpers.Response import ConvertingStream
1.8
1.9 class Transaction(Generic.Transaction):
1.10
1.11 @@ -24,6 +25,10 @@
1.12
1.13 self.request = request
1.14 self.response = request.RESPONSE
1.15 +
1.16 + # Attributes which may be changed later.
1.17 +
1.18 + self.content_type = None
1.19 self.user = None
1.20
1.21 # Request-related methods.
1.22 @@ -229,9 +234,13 @@
1.23 Returns the response stream for the transaction.
1.24 """
1.25
1.26 - # This yields a writable object.
1.27 + # Unicode can upset this operation. Using either the specified charset,
1.28 + # the same charset as that used in the request, or a default encoding.
1.29
1.30 - return self.response
1.31 + encoding = self.get_content_type().charset or "utf-8"
1.32 + if self.content_type:
1.33 + encoding = self.content_type.charset or encoding
1.34 + return ConvertingStream(self.response, encoding)
1.35
1.36 def get_response_code(self):
1.37
1.38 @@ -265,6 +274,7 @@
1.39 Sets the 'content_type' for the response.
1.40 """
1.41
1.42 + self.content_type = content_type
1.43 self.response.setHeader("Content-Type", self.format_content_type(content_type))
1.44
1.45 # Higher level response-related methods.