changeset 4607:d8e5e9cfadf1

always do 'from werkzeug import ...', except for contrib, exceptions, routing, script
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 23 Feb 2009 22:39:32 +0100
parents 619b1dacf4ee
children 3a79d3ca5a83
files MoinMoin/_tests/test_wikiutil.py MoinMoin/auth/http.py MoinMoin/web/contexts.py MoinMoin/web/profile.py MoinMoin/web/request.py MoinMoin/web/serving.py MoinMoin/web/session.py MoinMoin/web/utils.py MoinMoin/wikiutil.py
diffstat 9 files changed, 38 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/test_wikiutil.py	Sun Feb 22 23:22:18 2009 +0100
+++ b/MoinMoin/_tests/test_wikiutil.py	Mon Feb 23 22:39:32 2009 +0100
@@ -11,7 +11,7 @@
 
 from MoinMoin import config, wikiutil
 
-from werkzeug.utils import MultiDict
+from werkzeug import MultiDict
 
 
 class TestQueryStringSupport:
--- a/MoinMoin/auth/http.py	Sun Feb 22 23:22:18 2009 +0100
+++ b/MoinMoin/auth/http.py	Mon Feb 23 22:39:32 2009 +0100
@@ -84,8 +84,7 @@
             logging.debug("user: %r" % u)
 
         if not u or not u.valid:
-            from werkzeug import Response
-            from werkzeug.exceptions import abort
+            from werkzeug import Response, abort
             response = Response(_('Please log in first.'), 401,
                                 {'WWW-Authenticate': 'Basic realm="%s"' % self.realm})
             abort(response)
--- a/MoinMoin/web/contexts.py	Sun Feb 22 23:22:18 2009 +0100
+++ b/MoinMoin/web/contexts.py	Mon Feb 23 22:39:32 2009 +0100
@@ -10,8 +10,8 @@
 
 import time, inspect, StringIO, sys, warnings
 
-from werkzeug.utils import Headers, http_date, create_environ, redirect
-from werkzeug.exceptions import Unauthorized, NotFound, abort
+from werkzeug import Headers, http_date, create_environ, redirect, abort
+from werkzeug.exceptions import Unauthorized, NotFound
 
 from MoinMoin import i18n, error, user, config, wikiutil
 from MoinMoin.config import multiconfig
--- a/MoinMoin/web/profile.py	Sun Feb 22 23:22:18 2009 +0100
+++ b/MoinMoin/web/profile.py	Mon Feb 23 22:39:32 2009 +0100
@@ -18,7 +18,7 @@
     @copyright: 2008 MoinMoin:FlorianKrupicka,
     @license: GNU GPL, see COPYING for details.
 """
-from werkzeug.utils import get_current_url
+from werkzeug import get_current_url
 
 from MoinMoin import log
 logging = log.getLogger(__name__)
--- a/MoinMoin/web/request.py	Sun Feb 22 23:22:18 2009 +0100
+++ b/MoinMoin/web/request.py	Mon Feb 23 22:39:32 2009 +0100
@@ -9,12 +9,10 @@
 import re
 from StringIO import StringIO
 
-from werkzeug.wrappers import Request as WerkzeugRequest
-from werkzeug.wrappers import Response as WerkzeugResponse
-from werkzeug.utils import EnvironHeaders, cached_property, Href
-from werkzeug.utils import create_environ, url_encode
-from werkzeug.http import parse_cache_control_header, HeaderSet
-from werkzeug.test import Client
+from werkzeug import Request as WerkzeugRequest
+from werkzeug import Response as WerkzeugResponse
+from werkzeug import EnvironHeaders, cached_property, Href, create_environ
+from werkzeug import parse_cache_control_header, HeaderSet, url_encode, Client
 
 from MoinMoin import config
 
@@ -88,7 +86,7 @@
                  content_type=None, content_length=0, form_data=None,
                  environ_overrides=None):
         """
-        For parameter reference see the documentation of the werkzeug.utils
+        For parameter reference see the documentation of the werkzeug
         package, especially the functions `url_encode` and `create_environ`.
         """
         input_stream = None
--- a/MoinMoin/web/serving.py	Sun Feb 22 23:22:18 2009 +0100
+++ b/MoinMoin/web/serving.py	Mon Feb 23 22:39:32 2009 +0100
@@ -18,8 +18,8 @@
 import werkzeug._internal
 werkzeug._internal._logger = log.getLogger('werkzeug')
 
-from werkzeug.utils import SharedDataMiddleware
-from werkzeug.serving import BaseRequestHandler, run_simple
+from werkzeug import SharedDataMiddleware, run_simple
+from werkzeug.serving import BaseRequestHandler
 
 class RequestHandler(BaseRequestHandler):
     """
--- a/MoinMoin/web/session.py	Sun Feb 22 23:22:18 2009 +0100
+++ b/MoinMoin/web/session.py	Mon Feb 23 22:39:32 2009 +0100
@@ -12,7 +12,7 @@
 """
 import time
 
-from werkzeug.utils import dump_cookie
+from werkzeug import dump_cookie
 from werkzeug.contrib.sessions import FilesystemSessionStore, Session
 
 from MoinMoin import caching
--- a/MoinMoin/web/utils.py	Sun Feb 22 23:22:18 2009 +0100
+++ b/MoinMoin/web/utils.py	Mon Feb 23 22:39:32 2009 +0100
@@ -8,9 +8,7 @@
 """
 import time
 
-from werkzeug.exceptions import abort
-from werkzeug.utils import redirect, cookie_date
-from werkzeug.wrappers import Response
+from werkzeug import abort, redirect, cookie_date, Response
 
 from MoinMoin import caching
 from MoinMoin import log
--- a/MoinMoin/wikiutil.py	Sun Feb 22 23:22:18 2009 +0100
+++ b/MoinMoin/wikiutil.py	Mon Feb 23 22:39:32 2009 +0100
@@ -26,7 +26,7 @@
 from inspect import getargspec, isfunction, isclass, ismethod
 
 from MoinMoin import web # needed so that next line works:
-import werkzeug.utils
+import werkzeug
 
 # Exceptions
 class InvalidFileNameError(Exception):
@@ -91,38 +91,38 @@
 
 
 def url_quote(s, safe='/', want_unicode=None):
-    """ see werkzeug.utils.url_quote, we use a different safe param default value """
-    try:
-        assert want_unicode is None
-    except AssertionError:
-        log.exception("call with deprecated want_unicode param, please fix caller")
-    return werkzeug.utils.url_quote(s, charset=config.charset, safe=safe)
-
-def url_quote_plus(s, safe='/', want_unicode=None):
-    """ see werkzeug.utils.url_quote_plus, we use a different safe param default value """
+    """ see werkzeug.url_quote, we use a different safe param default value """
     try:
         assert want_unicode is None
     except AssertionError:
         log.exception("call with deprecated want_unicode param, please fix caller")
-    return werkzeug.utils.url_quote_plus(s, charset=config.charset, safe=safe)
+    return werkzeug.url_quote(s, charset=config.charset, safe=safe)
 
-def url_unquote(s, want_unicode=None):
-    """ see werkzeug.utils.url_unquote """
+def url_quote_plus(s, safe='/', want_unicode=None):
+    """ see werkzeug.url_quote_plus, we use a different safe param default value """
     try:
         assert want_unicode is None
     except AssertionError:
         log.exception("call with deprecated want_unicode param, please fix caller")
-    return werkzeug.utils.url_unquote(s, charset=config.charset, errors='fallback:iso-8859-1')
+    return werkzeug.url_quote_plus(s, charset=config.charset, safe=safe)
 
-
-def parseQueryString(qstr, want_unicode=None):
-    """ see werkzeug.utils.url_decode """
+def url_unquote(s, want_unicode=None):
+    """ see werkzeug.url_unquote """
     try:
         assert want_unicode is None
     except AssertionError:
         log.exception("call with deprecated want_unicode param, please fix caller")
-    return werkzeug.utils.url_decode(qstr, charset=config.charset, errors='fallback:iso-8859-1',
-                                     decode_keys=False, include_empty=False)
+    return werkzeug.url_unquote(s, charset=config.charset, errors='fallback:iso-8859-1')
+
+
+def parseQueryString(qstr, want_unicode=None):
+    """ see werkzeug.url_decode """
+    try:
+        assert want_unicode is None
+    except AssertionError:
+        log.exception("call with deprecated want_unicode param, please fix caller")
+    return werkzeug.url_decode(qstr, charset=config.charset, errors='fallback:iso-8859-1',
+                               decode_keys=False, include_empty=False)
 
 def makeQueryString(qstr=None, want_unicode=None, **kw):
     """ Make a querystring from arguments.
@@ -131,7 +131,7 @@
 
     If a string is passed in, it's returned verbatim and keyword parameters are ignored.
 
-    See also: werkzeug.utils.url_encode
+    See also: werkzeug.url_encode
 
     @param qstr: dict to format as query string, using either ascii or unicode
     @param kw: same as dict when using keywords, using ascii or unicode
@@ -148,7 +148,7 @@
         return qstr
     if isinstance(qstr, dict):
         qstr.update(kw)
-        return werkzeug.utils.url_encode(qstr, charset=config.charset, encode_keys=True)
+        return werkzeug.url_encode(qstr, charset=config.charset, encode_keys=True)
     else:
         raise ValueError("Unsupported argument type, should be dict.")
 
@@ -165,12 +165,12 @@
     @rtype: string
     @return: the quoted filename, all unsafe characters encoded
     """
-    # XXX please note that urllib.quote and werkzeug.utils.url_quote have
+    # XXX please note that urllib.quote and werkzeug.url_quote have
     # XXX different defaults for safe=...
-    return werkzeug.utils.url_quote(pagename, charset=charset, safe='/')
+    return werkzeug.url_quote(pagename, charset=charset, safe='/')
 
 
-escape = werkzeug.utils.escape
+escape = werkzeug.escape
 
 
 def clean_input(text, max_len=201):