1.1 --- a/WebStack/Resources/Selectors.py Sat Jan 20 23:15:19 2007 +0000
1.2 +++ b/WebStack/Resources/Selectors.py Sat Jan 20 23:15:29 2007 +0000
1.3 @@ -51,7 +51,8 @@
1.4
1.5 """
1.6 Respond to the transaction 'trans' by storing the current path and
1.7 - processed virtual path info on the named transaction attribute.
1.8 + processed virtual path info on the named transaction attribute, then
1.9 + forwarding the transaction to the previously specified resource.
1.10 """
1.11
1.12 pwi = trans.get_path_without_info(self.path_encoding)
1.13 @@ -68,4 +69,34 @@
1.14
1.15 self.resource.respond(trans)
1.16
1.17 +class EncodingSelector:
1.18 +
1.19 + """
1.20 + Set the default encoding (or "charset") on transactions presented to this
1.21 + resource.
1.22 + """
1.23 +
1.24 + def __init__(self, resource, encoding):
1.25 +
1.26 + """
1.27 + Initialise the selector with a 'resource' (to which all requests shall
1.28 + be forwarded), specifying the 'encoding' which shall be used as the
1.29 + default encoding (or "charset") for all transactions handled by this
1.30 + resource.
1.31 + """
1.32 +
1.33 + self.resource = resource
1.34 + self.encoding = encoding
1.35 +
1.36 + def respond(self, trans):
1.37 +
1.38 + """
1.39 + Respond to the transaction 'trans' by setting the default encoding (or
1.40 + "charset") on 'trans', then forwarding the transaction to the previously
1.41 + specified resource.
1.42 + """
1.43 +
1.44 + trans.default_charset = self.encoding
1.45 + self.resource.respond(trans)
1.46 +
1.47 # vim: tabstop=4 expandtab shiftwidth=4