changeset 6010:fc1f97a47c7e

upgrade bundled werkzeug to 0.8.3
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 05 Jan 2014 03:44:28 +0100
parents b48a69886ca4
children 0fe01a3a2c32
files MoinMoin/support/werkzeug/__init__.py MoinMoin/support/werkzeug/contrib/cache.py MoinMoin/support/werkzeug/debug/console.py MoinMoin/support/werkzeug/debug/shared/console.png MoinMoin/support/werkzeug/debug/shared/less.png MoinMoin/support/werkzeug/debug/shared/more.png MoinMoin/support/werkzeug/debug/shared/source.png MoinMoin/support/werkzeug/debug/shared/ubuntu.ttf MoinMoin/support/werkzeug/routing.py MoinMoin/support/werkzeug/serving.py MoinMoin/support/werkzeug/utils.py MoinMoin/support/werkzeug/wrappers.py MoinMoin/support/werkzeug/wsgi.py docs/CHANGES docs/REQUIREMENTS
diffstat 11 files changed, 70 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/support/werkzeug/__init__.py	Sun Jan 05 02:49:41 2014 +0100
+++ b/MoinMoin/support/werkzeug/__init__.py	Sun Jan 05 03:44:28 2014 +0100
@@ -19,7 +19,7 @@
 
 
 # the version.  Usually set automatically by a script.
-__version__ = '0.8.1'
+__version__ = '0.8.3'
 
 
 # This import magic raises concerns quite often which is why the implementation
--- a/MoinMoin/support/werkzeug/contrib/cache.py	Sun Jan 05 02:49:41 2014 +0100
+++ b/MoinMoin/support/werkzeug/contrib/cache.py	Sun Jan 05 03:44:28 2014 +0100
@@ -471,15 +471,15 @@
     :param key_prefix: A prefix that should be added to all keys.
     """
 
-    def __init__(self, host='localhost', port=6379, default_timeout=300,
-                 key_prefix=None):
+    def __init__(self, host='localhost', port=6379, password=None,
+                 default_timeout=300, key_prefix=None):
         BaseCache.__init__(self, default_timeout)
         if isinstance(host, basestring):
             try:
                 import redis
             except ImportError:
                 raise RuntimeError('no redis module found')
-            self._client = redis.Redis(host=host, port=port)
+            self._client = redis.Redis(host=host, port=port, password=password)
         else:
             self._client = host
         self.key_prefix = key_prefix or ''
@@ -488,7 +488,8 @@
         """Dumps an object into a string for redis.  By default it serializes
         integers as regular string and pickle dumps everything else.
         """
-        if isinstance(value, (int, long)):
+        t = type(value)
+        if t is int or t is long:
             return str(value)
         return '!' + pickle.dumps(value)
 
--- a/MoinMoin/support/werkzeug/debug/console.py	Sun Jan 05 02:49:41 2014 +0100
+++ b/MoinMoin/support/werkzeug/debug/console.py	Sun Jan 05 03:44:28 2014 +0100
@@ -201,4 +201,8 @@
         self._ipy = _InteractiveConsole(globals, locals)
 
     def eval(self, code):
-        return self._ipy.runsource(code)
+        old_sys_stdout = sys.stdout
+        try:
+            return self._ipy.runsource(code)
+        finally:
+            sys.stdout = old_sys_stdout
Binary file MoinMoin/support/werkzeug/debug/shared/ubuntu.ttf has changed
--- a/MoinMoin/support/werkzeug/routing.py	Sun Jan 05 02:49:41 2014 +0100
+++ b/MoinMoin/support/werkzeug/routing.py	Sun Jan 05 03:44:28 2014 +0100
@@ -240,7 +240,7 @@
         self.new_url = new_url
 
     def get_response(self, environ):
-        return redirect(self.new_url, 301)
+        return redirect(self.new_url, self.code)
 
 
 class RequestSlash(RoutingException):
@@ -715,7 +715,7 @@
                     return
                 processed.add(data)
             else:
-                add(data)
+                add(url_quote(data, self.map.charset, safe='/:|'))
         domain_part, url = (u''.join(tmp)).split('|', 1)
 
         if append_unknown:
@@ -1121,6 +1121,8 @@
             subdomain = self.default_subdomain
         if script_name is None:
             script_name = '/'
+        if isinstance(server_name, unicode):
+            server_name = server_name.encode('idna')
         return MapAdapter(self, server_name, script_name, subdomain,
                           url_scheme, path_info, default_method, query_args)
 
--- a/MoinMoin/support/werkzeug/serving.py	Sun Jan 05 02:49:41 2014 +0100
+++ b/MoinMoin/support/werkzeug/serving.py	Sun Jan 05 03:44:28 2014 +0100
@@ -177,6 +177,7 @@
 
     def handle(self):
         """Handles a request ignoring dropped connections."""
+        rv = None
         try:
             rv = BaseHTTPRequestHandler.handle(self)
         except (socket.error, socket.timeout), e:
@@ -192,9 +193,11 @@
         """A horrible, horrible way to kill the server for Python 2.6 and
         later.  It's the best we can do.
         """
+        # Windows does not provide SIGKILL, go with SIGTERM then.
+        sig = getattr(signal, 'SIGKILL', signal.SIGTERM)
         # reloader active
         if os.environ.get('WERKZEUG_RUN_MAIN') == 'true':
-            os.kill(os.getpid(), signal.SIGKILL)
+            os.kill(os.getpid(), sig)
         # python 2.7
         self.server._BaseServer__shutdown_request = True
         # python 2.6
--- a/MoinMoin/support/werkzeug/utils.py	Sun Jan 05 02:49:41 2014 +0100
+++ b/MoinMoin/support/werkzeug/utils.py	Sun Jan 05 03:44:28 2014 +0100
@@ -189,10 +189,10 @@
                     buffer += '>'
                 return buffer
             buffer += '>'
-            
+
             children_as_string = ''.join([unicode(x) for x in children
                                          if x is not None])
-            
+
             if children_as_string:
                 if tag in self._plaintext_elements:
                     children_as_string = escape(children_as_string)
@@ -353,7 +353,7 @@
     :param code: the redirect status code. defaults to 302.
     """
     from werkzeug.wrappers import BaseResponse
-    display_location = location
+    display_location = escape(location)
     if isinstance(location, unicode):
         from werkzeug.urls import iri_to_uri
         location = iri_to_uri(location)
@@ -363,7 +363,7 @@
         '<h1>Redirecting...</h1>\n'
         '<p>You should be redirected automatically to target URL: '
         '<a href="%s">%s</a>.  If not click the link.' %
-        (location, display_location), code, mimetype='text/html')
+        (escape(location, True), display_location), code, mimetype='text/html')
     response.headers['Location'] = location
     return response
 
@@ -586,7 +586,7 @@
             name += (name and '.') + part
             imported = import_string(name, silent=True)
             if imported:
-                tracked.append((name, imported.__file__))
+                tracked.append((name, getattr(imported, '__file__', None)))
             else:
                 track = ['- %r found in %r.' % (n, i) for n, i in tracked]
                 track.append('- %r not found.' % name)
--- a/MoinMoin/support/werkzeug/wrappers.py	Sun Jan 05 02:49:41 2014 +0100
+++ b/MoinMoin/support/werkzeug/wrappers.py	Sun Jan 05 03:44:28 2014 +0100
@@ -737,7 +737,7 @@
         except KeyError:
             self._status = '%d UNKNOWN' % code
     status_code = property(_get_status_code, _set_status_code,
-                           'The HTTP Status code as number')
+                           doc='The HTTP Status code as number')
     del _get_status_code, _set_status_code
 
     def _get_status(self):
@@ -748,7 +748,7 @@
             self._status_code = int(self._status.split(None, 1)[0])
         except ValueError:
             self._status_code = 0
-    status = property(_get_status, _set_status, 'The HTTP Status code')
+    status = property(_get_status, _set_status, doc='The HTTP Status code')
     del _get_status, _set_status
 
     def _get_data(self):
--- a/MoinMoin/support/werkzeug/wsgi.py	Sun Jan 05 02:49:41 2014 +0100
+++ b/MoinMoin/support/werkzeug/wsgi.py	Sun Jan 05 03:44:28 2014 +0100
@@ -604,30 +604,52 @@
     :param buffer_size: The optional buffer size.
     """
     stream = make_limited_stream(stream, limit)
-    _read = stream.read
-    buffer = []
-    while 1:
-        if len(buffer) > 1:
-            yield buffer.pop()
-            continue
+    def _iter_basic_lines():
+        _read = stream.read
+        buffer = []
+        while 1:
+            if len(buffer) > 1:
+                yield buffer.pop()
+                continue
 
-        # we reverse the chunks because popping from the last
-        # position of the list is O(1) and the number of chunks
-        # read will be quite large for binary files.
-        chunks = _read(buffer_size).splitlines(True)
-        chunks.reverse()
+            # we reverse the chunks because popping from the last
+            # position of the list is O(1) and the number of chunks
+            # read will be quite large for binary files.
+            chunks = _read(buffer_size).splitlines(True)
+            chunks.reverse()
 
-        first_chunk = buffer and buffer[0] or ''
-        if chunks:
-            if first_chunk.endswith('\n') or first_chunk.endswith('\r'):
+            first_chunk = buffer and buffer[0] or ''
+            if chunks:
+                if first_chunk and first_chunk[-1] in '\r\n':
+                    yield first_chunk
+                    first_chunk = ''
+                first_chunk += chunks.pop()
+            else:
                 yield first_chunk
-                first_chunk = ''
-            first_chunk += chunks.pop()
-        if not first_chunk:
-            return
+                break
 
-        buffer = chunks
-        yield first_chunk
+            buffer = chunks
+
+            # in case the line is longer than the buffer size we
+            # can't yield yet.  This will only happen if the buffer
+            # is empty.
+            if not buffer and first_chunk[-1] not in '\r\n':
+                buffer = [first_chunk]
+            else:
+                yield first_chunk
+
+    # This hackery is necessary to merge 'foo\r' and '\n' into one item
+    # of 'foo\r\n' if we were unlucky and we hit a chunk boundary.
+    previous = ''
+    for item in _iter_basic_lines():
+        if item == '\n' and previous[-1:] == '\r':
+            previous += '\n'
+            item = ''
+        if previous:
+            yield previous
+        previous = item
+    if previous:
+        yield previous
 
 
 def make_chunk_iter(stream, separator, limit=None, buffer_size=10 * 1024):
--- a/docs/CHANGES	Sun Jan 05 02:49:41 2014 +0100
+++ b/docs/CHANGES	Sun Jan 05 03:44:28 2014 +0100
@@ -86,6 +86,7 @@
     when requested for a specific single page. As we have a link to this in
     every page's html output, this likely also lightens the load caused by bots
     and search engine crawlers.
+  * upgraded bundled werkzeug to 0.8.3
   * upgraded bundled passlib to 1.6.2
   * upgraded bundled pygments to 1.6
 
--- a/docs/REQUIREMENTS	Sun Jan 05 02:49:41 2014 +0100
+++ b/docs/REQUIREMENTS	Sun Jan 05 03:44:28 2014 +0100
@@ -131,7 +131,7 @@
 
 werkzeug (WSGI toolkit)
 =======================
-shipped: 0.8.1
+shipped: 0.8.3  (note: 0.9.x requires python >= 2.6)
 minimum: 0.7.0
 
 Note: >= 0.6.1 will also likely work if the missing "import sys" in