diff options
author | pjenvey <devnull@localhost> | 2007-01-22 03:50:53 +0000 |
---|---|---|
committer | pjenvey <devnull@localhost> | 2007-01-22 03:50:53 +0000 |
commit | 09df81aa57e768c5d0f6b26b23e9f9f02096ec6b (patch) | |
tree | e2fcd98ca3e00dda71dece3ac2489f579ad70040 /paste/wsgiwrappers.py | |
parent | 4a2ca4cc0bdaa79a00f6a4979d43be59b03063bf (diff) | |
download | paste-09df81aa57e768c5d0f6b26b23e9f9f02096ec6b.tar.gz |
by default don't have WSGIRequest decode parameter keys when unicode params are expected.
allow this behavior when WSGIRequest.decode_param_names is enabled
Diffstat (limited to 'paste/wsgiwrappers.py')
-rw-r--r-- | paste/wsgiwrappers.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/paste/wsgiwrappers.py b/paste/wsgiwrappers.py index 2e7a667..15ad1c1 100644 --- a/paste/wsgiwrappers.py +++ b/paste/wsgiwrappers.py @@ -57,10 +57,14 @@ class WSGIRequest(object): to express nothing beyond what is available in the environment dictionary. - The only state maintained in this object is the desired ``charset`` - and its associated ``errors`` handler. The incoming parameters will - be automatically coerced to unicode objects of the ``charset`` - encoding when ``charset`` is set. + The only state maintained in this object is the desired ``charset``, + its associated ``errors`` handler, and the ``decode_param_names`` + option. + + The incoming parameter values will be automatically coerced to unicode + objects of the ``charset`` encoding when ``charset`` is set. The + incoming parameter names are not decoded to unicode unless the + ``decode_param_names`` option is enabled. When unicode is expected, ``charset`` will overridden by the the value of the ``Content-Type`` header's charset parameter if one was @@ -76,7 +80,8 @@ class WSGIRequest(object): You are free to subclass this object. """ - defaults = StackedObjectProxy(default=dict(charset=None, errors='strict')) + defaults = StackedObjectProxy(default=dict(charset=None, errors='strict', + decode_param_names=False)) def __init__(self, environ): self.environ = environ # This isn't "state" really, since the object is derivative: @@ -91,6 +96,7 @@ class WSGIRequest(object): if browser_charset: self.charset = browser_charset self.errors = defaults.get('errors', 'strict') + self.decode_param_names = defaults.get('decode_param_names', False) body = environ_getter('wsgi.input') scheme = environ_getter('wsgi.url_scheme') @@ -127,7 +133,8 @@ class WSGIRequest(object): params = self._GET() if self.charset: params = UnicodeMultiDict(params, encoding=self.charset, - errors=self.errors) + errors=self.errors, + decode_keys=self.decode_param_names) return params GET = property(GET, doc=GET.__doc__) @@ -153,7 +160,8 @@ class WSGIRequest(object): params = self._POST() if self.charset: params = UnicodeMultiDict(params, encoding=self.charset, - errors=self.errors) + errors=self.errors, + decode_keys=self.decode_param_names) return params POST = property(POST, doc=POST.__doc__) @@ -177,7 +185,8 @@ class WSGIRequest(object): params.update(self._GET()) if self.charset: params = UnicodeMultiDict(params, encoding=self.charset, - errors=self.errors) + errors=self.errors, + decode_keys=self.decode_param_names) return params params = property(params, doc=params.__doc__) |