# HG changeset patch # User paulb # Date 1124920741 0 # Node ID a7de8c863a8fa58f3f0fe18b4f673e3a8785f3b1 # Parent 2694c6ea2fbec673e7772df67b058847960ecc1f [project @ 2005-08-24 21:59:01 by paulb] Removal of an inappropriate line in some example code. diff -r 2694c6ea2fbe -r a7de8c863a8f docs/encodings.html --- a/docs/encodings.html Wed Aug 24 21:58:49 2005 +0000 +++ b/docs/encodings.html Wed Aug 24 21:59:01 2005 +0000 @@ -3,7 +3,6 @@
When writing applications with WebStack, you should try and use @@ -53,7 +52,7 @@ module contains useful functions to access streams as if Unicode objects were being transmitted; for example: -
import codecs+
class MyResource:
encoding = "utf-8"
def respond(self, trans):
stream = trans.get_request_stream() # only reads strings
unicode_stream = codecs.getreader(self.encoding)(stream) # reads Unicode objects
[Some activity...]
out = trans.get_response_stream() # only writes strings
unicode_out = codecs.getwriter(self.encoding)(out) # writes Unicode objects
import codecs
class MyResource:
encoding = "utf-8"
def respond(self, trans):
stream = trans.get_request_stream() # only reads strings
unicode_stream = codecs.getreader(self.encoding)(stream) # reads Unicode objects
[Some activity...]
out = trans.get_response_stream() # writes strings and Unicode objects
If you are reading and writing binary content, Unicode objects are inappropriate. Make sure to open files in binary mode, where necessary.