summaryrefslogtreecommitdiff
path: root/paste/wsgiwrappers.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-04-21 15:26:47 +0200
committerVictor Stinner <victor.stinner@gmail.com>2015-04-21 15:26:47 +0200
commit04ecd5542849191457ccfc3e42a39452db47825a (patch)
treeb0a470e46326b709d090a900847bbb004d355607 /paste/wsgiwrappers.py
parent4c177fce89fee925f0f4fbfde00ce2e1252562c0 (diff)
downloadpaste-04ecd5542849191457ccfc3e42a39452db47825a.tar.gz
Strip trailing spaces
Diffstat (limited to 'paste/wsgiwrappers.py')
-rw-r--r--paste/wsgiwrappers.py46
1 files changed, 23 insertions, 23 deletions
diff --git a/paste/wsgiwrappers.py b/paste/wsgiwrappers.py
index 9b614ec..290179d 100644
--- a/paste/wsgiwrappers.py
+++ b/paste/wsgiwrappers.py
@@ -84,18 +84,18 @@ class WSGIRequest(object):
The class variable ``defaults`` specifies default values for
``charset``, ``errors``, and ``langauge``. These can be overridden for the
current request via the registry.
-
+
The ``language`` default value is considered the fallback during i18n
translations to ensure in odd cases that mixed languages don't occur should
the ``language`` file contain the string but not another language in the
accepted languages list. The ``language`` value only applies when getting
a list of accepted languages from the HTTP Accept header.
-
+
This behavior is duplicated from Aquarium, and may seem strange but is
- very useful. Normally, everything in the code is in "en-us". However,
+ very useful. Normally, everything in the code is in "en-us". However,
the "en-us" translation catalog is usually empty. If the user requests
``["en-us", "zh-cn"]`` and a translation isn't found for a string in
- "en-us", you don't want gettext to fallback to "zh-cn". You want it to
+ "en-us", you don't want gettext to fallback to "zh-cn". You want it to
just use the string itself. Hence, if a string isn't found in the
``language`` catalog, the string in the source code will be used.
@@ -112,7 +112,7 @@ class WSGIRequest(object):
self.environ = environ
# This isn't "state" really, since the object is derivative:
self.headers = EnvironHeaders(environ)
-
+
defaults = self.defaults._current_obj()
self.charset = defaults.get('charset')
if self.charset:
@@ -124,7 +124,7 @@ class WSGIRequest(object):
self.errors = defaults.get('errors', 'strict')
self.decode_param_names = defaults.get('decode_param_names', False)
self._languages = None
-
+
body = environ_getter('wsgi.input')
scheme = environ_getter('wsgi.url_scheme')
method = environ_getter('REQUEST_METHOD')
@@ -143,12 +143,12 @@ class WSGIRequest(object):
else:
return {}
urlvars = property(urlvars, doc=urlvars.__doc__)
-
+
def is_xhr(self):
"""Returns a boolean if X-Requested-With is present and a XMLHttpRequest"""
return self.environ.get('HTTP_X_REQUESTED_WITH', '') == 'XMLHttpRequest'
is_xhr = property(is_xhr, doc=is_xhr.__doc__)
-
+
def host(self):
"""Host name provided in HTTP_HOST, with fall-back to SERVER_NAME"""
return self.environ.get('HTTP_HOST', self.environ.get('SERVER_NAME'))
@@ -156,7 +156,7 @@ class WSGIRequest(object):
def languages(self):
"""Return a list of preferred languages, most preferred first.
-
+
The list may be empty.
"""
if self._languages is not None:
@@ -173,7 +173,7 @@ class WSGIRequest(object):
self._languages = langs
return self._languages
languages = property(languages, doc=languages.__doc__)
-
+
def _GET(self):
return parse_dict_querystring(self.environ)
@@ -253,7 +253,7 @@ class WSGIRequest(object):
"""Dictionary of cookies keyed by cookie name.
Just a plain dictionary, may be empty but not None.
-
+
"""
return get_cookie_dict(self.environ)
cookies = property(cookies, doc=cookies.__doc__)
@@ -270,7 +270,7 @@ class WSGIRequest(object):
def match_accept(self, mimetypes):
"""Return a list of specified mime-types that the browser's HTTP Accept
header allows in the order provided."""
- return desired_matches(mimetypes,
+ return desired_matches(mimetypes,
self.environ.get('HTTP_ACCEPT', '*/*'))
def __repr__(self):
@@ -300,7 +300,7 @@ class WSGIResponse(object):
"""
defaults = StackedObjectProxy(
- default=dict(content_type='text/html', charset='utf-8',
+ default=dict(content_type='text/html', charset='utf-8',
errors='strict', headers={'Cache-Control':'no-cache'})
)
def __init__(self, content='', mimetype=None, code=200):
@@ -335,14 +335,14 @@ class WSGIResponse(object):
return '\n'.join(['%s: %s' % (key, value)
for key, value in self.headers.headeritems()]) \
+ '\n\n' + content
-
+
def __call__(self, environ, start_response):
"""Convenience call to return output and set status information
-
+
Conforms to the WSGI interface for calling purposes only.
-
+
Example usage:
-
+
.. code-block:: python
def wsgi_app(environ, start_response):
@@ -350,7 +350,7 @@ class WSGIResponse(object):
response.write("Hello world")
response.headers['Content-Type'] = 'latin1'
return response(environ, start_response)
-
+
"""
status_text = STATUS_CODE_TEXT[self.status_code]
status = '%s %s' % (self.status_code, status_text)
@@ -364,7 +364,7 @@ class WSGIResponse(object):
elif is_file:
return iter(lambda: self.content.read(), '')
return self.get_content()
-
+
def determine_charset(self):
"""
Determine the encoding as specified by the Content-Type's charset
@@ -373,7 +373,7 @@ class WSGIResponse(object):
charset_match = _CHARSET_RE.search(self.headers.get('Content-Type', ''))
if charset_match:
return charset_match.group(1)
-
+
def has_header(self, header):
"""
Case-insensitive check for a header
@@ -434,7 +434,7 @@ class WSGIResponse(object):
return encode_unicode_app_iter(self.content, charset, self.errors)
else:
return self.content
-
+
def wsgi_response(self):
"""
Return this WSGIResponse as a tuple of WSGI formatted data, including:
@@ -446,12 +446,12 @@ class WSGIResponse(object):
for c in self.cookies.values():
response_headers.append(('Set-Cookie', c.output(header='')))
return status, response_headers, self.get_content()
-
+
# The remaining methods partially implement the file-like object interface.
# See http://docs.python.org/lib/bltin-file-objects.html
def write(self, content):
if not self._is_str_iter:
- raise IOError("This %s instance's content is not writable: (content "
+ raise IOError("This %s instance's content is not writable: (content "
'is an iterator)' % self.__class__.__name__)
self.content.append(content)