changeset 109:e4c332436733

remove flask monkeypatch, use 'from flask import g as flaskg'
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 12 Mar 2011 15:28:21 +0100
parents f789b04b44fd
children 713df2332b89
files MoinMoin/_tests/__init__.py MoinMoin/_tests/test_test_environ.py MoinMoin/_tests/test_user.py MoinMoin/app.py MoinMoin/apps/admin/views.py MoinMoin/apps/feed/views.py MoinMoin/apps/frontend/_tests/test_frontend.py MoinMoin/apps/frontend/views.py MoinMoin/apps/misc/views.py MoinMoin/auth/__init__.py MoinMoin/converter/include.py MoinMoin/converter/link.py MoinMoin/converter/rst_in.py MoinMoin/datastruct/backends/__init__.py MoinMoin/datastruct/backends/_tests/__init__.py MoinMoin/datastruct/backends/_tests/test_composite_groups.py MoinMoin/datastruct/backends/_tests/test_wiki_groups.py MoinMoin/datastruct/backends/wiki_dicts.py MoinMoin/datastruct/backends/wiki_groups.py MoinMoin/i18n/__init__.py MoinMoin/items/__init__.py MoinMoin/items/_tests/test_Item.py MoinMoin/macro/Date.py MoinMoin/macro/DateTime.py MoinMoin/macro/GetVal.py MoinMoin/macro/MailTo.py MoinMoin/macro/PagenameList.py MoinMoin/macro/RandomItem.py MoinMoin/script/account/create.py MoinMoin/script/account/disable.py MoinMoin/script/account/resetpw.py MoinMoin/script/maint/create_item.py MoinMoin/script/maint/set_meta.py MoinMoin/script/maint/xml.py MoinMoin/security/__init__.py MoinMoin/security/_tests/test_security.py MoinMoin/security/textcha.py MoinMoin/security/ticket.py MoinMoin/storage/_tests/test_backends.py MoinMoin/storage/_tests/test_middleware_acl.py MoinMoin/storage/_tests/test_serialization.py MoinMoin/storage/backends/__init__.py MoinMoin/storage/backends/acl.py MoinMoin/themes/__init__.py MoinMoin/user.py MoinMoin/util/interwiki.py MoinMoin/util/monkeypatch.py MoinMoin/wikiutil.py
diffstat 48 files changed, 57 insertions(+), 61 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/_tests/__init__.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/_tests/__init__.py	Sat Mar 12 15:28:21 2011 +0100
@@ -11,8 +11,7 @@
 import os, shutil
 
 from flask import current_app as app
-from flask import flaskg
-
+from flask import g as flaskg
 
 from MoinMoin import config, security, user
 from MoinMoin.items import Item
--- a/MoinMoin/_tests/test_test_environ.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/_tests/test_test_environ.py	Sat Mar 12 15:28:21 2011 +0100
@@ -9,7 +9,7 @@
 import py
 
 from flask import current_app as app
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin.config import IS_SYSITEM, SYSITEM_VERSION
 from MoinMoin.storage.error import NoSuchItemError
--- a/MoinMoin/_tests/test_user.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/_tests/test_user.py	Sat Mar 12 15:28:21 2011 +0100
@@ -11,7 +11,7 @@
 import py
 
 from flask import current_app as app
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin import user
 
--- a/MoinMoin/app.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/app.py	Sat Mar 12 15:28:21 2011 +0100
@@ -16,8 +16,9 @@
 # "import MoinMoin" from setup.py even before flask, werkzeug, ... is installed.
 from MoinMoin.util import monkeypatch
 
-from flask import Flask, request, session, flaskg
+from flask import Flask, request, session
 from flask import current_app as app
+from flask import g as flaskg
 
 from flaskext.cache import Cache
 from flaskext.themes import setup_themes
--- a/MoinMoin/apps/admin/views.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/apps/admin/views.py	Sat Mar 12 15:28:21 2011 +0100
@@ -15,7 +15,7 @@
 
 from flask import request, url_for, flash, redirect, abort
 from flask import current_app as app
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin.i18n import _, L_, N_
 from MoinMoin.themes import render_template
--- a/MoinMoin/apps/feed/views.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/apps/feed/views.py	Sat Mar 12 15:28:21 2011 +0100
@@ -12,9 +12,8 @@
 from datetime import datetime
 
 from flask import request, url_for, Response
-from flask import flaskg
-
 from flask import current_app as app
+from flask import g as flaskg
 
 from werkzeug.contrib.atom import AtomFeed
 
--- a/MoinMoin/apps/frontend/_tests/test_frontend.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/apps/frontend/_tests/test_frontend.py	Sat Mar 12 15:28:21 2011 +0100
@@ -6,9 +6,10 @@
     MoinMoin - basic tests for frontend
 """
 
+from flask import g as flaskg
+from werkzeug import ImmutableMultiDict
+
 from MoinMoin.apps.frontend import views
-from werkzeug import ImmutableMultiDict
-from flask import flaskg
 from MoinMoin import user
 
 class TestFrontend(object):
--- a/MoinMoin/apps/frontend/views.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/apps/frontend/views.py	Sat Mar 12 15:28:21 2011 +0100
@@ -18,8 +18,8 @@
 from itertools import chain
 
 from flask import request, url_for, flash, Response, redirect, session, abort
-from flask import flaskg
 from flask import current_app as app
+from flask import g as flaskg
 from flaskext.themes import get_themes_list
 
 from flatland import Form, String, Integer, Boolean, Enum
--- a/MoinMoin/apps/misc/views.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/apps/misc/views.py	Sat Mar 12 15:28:21 2011 +0100
@@ -11,9 +11,8 @@
 import time
 
 from flask import Response
-from flask import flaskg
-
 from flask import current_app as app
+from flask import g as flaskg
 
 from MoinMoin.apps.misc import misc
 
--- a/MoinMoin/auth/__init__.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/auth/__init__.py	Sat Mar 12 15:28:21 2011 +0100
@@ -140,7 +140,7 @@
 
 from werkzeug import redirect, abort, url_quote, url_quote_plus
 from flask import url_for, session, request
-from flask import flaskg
+from flask import g as flaskg
 from flask import current_app as app
 from jinja2 import Markup
 
--- a/MoinMoin/converter/include.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/converter/include.py	Sat Mar 12 15:28:21 2011 +0100
@@ -17,7 +17,7 @@
 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin import wikiutil
 from MoinMoin.items import Item
--- a/MoinMoin/converter/link.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/converter/link.py	Sat Mar 12 15:28:21 2011 +0100
@@ -11,7 +11,7 @@
 
 from __future__ import absolute_import
 
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin.util.interwiki import resolve_interwiki, join_wiki
 from MoinMoin.util.iri import Iri, IriPath
--- a/MoinMoin/converter/rst_in.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/converter/rst_in.py	Sat Mar 12 15:28:21 2011 +0100
@@ -22,7 +22,7 @@
 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin import config, wikiutil
 from MoinMoin.util.iri import Iri
--- a/MoinMoin/datastruct/backends/__init__.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/datastruct/backends/__init__.py	Sat Mar 12 15:28:21 2011 +0100
@@ -9,7 +9,8 @@
 from UserDict import DictMixin
 
 from flask import current_app as app
-from flask import flaskg
+from flask import g as flaskg
+
 
 class GroupDoesNotExistError(Exception):
     """
--- a/MoinMoin/datastruct/backends/_tests/__init__.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/datastruct/backends/_tests/__init__.py	Sat Mar 12 15:28:21 2011 +0100
@@ -12,7 +12,7 @@
 from py.test import raises
 
 from flask import current_app as app
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin import security
 from MoinMoin.datastruct import GroupDoesNotExistError
--- a/MoinMoin/datastruct/backends/_tests/test_composite_groups.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/datastruct/backends/_tests/test_composite_groups.py	Sat Mar 12 15:28:21 2011 +0100
@@ -8,7 +8,7 @@
 
 from py.test import raises
 
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin.datastruct.backends._tests import GroupsBackendTest
 from MoinMoin.datastruct import ConfigGroups, CompositeGroups, GroupDoesNotExistError
--- a/MoinMoin/datastruct/backends/_tests/test_wiki_groups.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/datastruct/backends/_tests/test_wiki_groups.py	Sat Mar 12 15:28:21 2011 +0100
@@ -13,7 +13,8 @@
 import py
 
 from flask import current_app as app
-from flask import flaskg
+from flask import g as flaskg
+
 from MoinMoin.datastruct.backends._tests import GroupsBackendTest
 from MoinMoin.datastruct import GroupDoesNotExistError
 from MoinMoin.config import USERGROUP
--- a/MoinMoin/datastruct/backends/wiki_dicts.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/datastruct/backends/wiki_dicts.py	Sat Mar 12 15:28:21 2011 +0100
@@ -9,7 +9,8 @@
 """
 
 
-from flask import flaskg
+from flask import g as flaskg
+
 from MoinMoin.config import SOMEDICT
 from MoinMoin.datastruct.backends import BaseDict, BaseDictsBackend, DictDoesNotExistError
 
--- a/MoinMoin/datastruct/backends/wiki_groups.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/datastruct/backends/wiki_groups.py	Sat Mar 12 15:28:21 2011 +0100
@@ -14,7 +14,8 @@
 HelpOnConfiguration.
 """
 
-from flask import flaskg
+from flask import g as flaskg
+
 from MoinMoin.config import USERGROUP
 from MoinMoin.datastruct.backends import GreedyGroup, BaseGroupsBackend, GroupDoesNotExistError
 
--- a/MoinMoin/i18n/__init__.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/i18n/__init__.py	Sat Mar 12 15:28:21 2011 +0100
@@ -16,7 +16,8 @@
 
 from babel import Locale
 
-from flask import current_app, request, flaskg
+from flask import current_app, request
+from flask import g as flaskg
 from flaskext.babel import Babel, gettext, ngettext, lazy_gettext
 
 _ = gettext
--- a/MoinMoin/items/__init__.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/items/__init__.py	Sat Mar 12 15:28:21 2011 +0100
@@ -39,7 +39,7 @@
     import simplejson as json
 
 from flask import current_app as app
-from flask import flaskg
+from flask import g as flaskg
 
 from flask import request, url_for, Response, abort, escape
 from werkzeug import is_resource_modified
--- a/MoinMoin/items/_tests/test_Item.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/items/_tests/test_Item.py	Sat Mar 12 15:28:21 2011 +0100
@@ -8,7 +8,7 @@
 
 import py
 
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin._tests import become_trusted
 from MoinMoin.items import Item, ApplicationXTar, NonExistent, Binary, Text, Image, TransformableBitmapImage
--- a/MoinMoin/macro/Date.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/macro/Date.py	Sat Mar 12 15:28:21 2011 +0100
@@ -10,7 +10,7 @@
 import time
 from datetime import datetime
 
-from flask import flaskg
+from flask import g as flaskg
 from flaskext.babel import format_date
 
 from MoinMoin.macro._base import MacroInlineBase
--- a/MoinMoin/macro/DateTime.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/macro/DateTime.py	Sat Mar 12 15:28:21 2011 +0100
@@ -9,7 +9,7 @@
 import time
 from datetime import datetime
 
-from flask import flaskg
+from flask import g as flaskg
 from flaskext.babel import format_datetime
 
 from MoinMoin.macro.Date import MacroDateTimeBase
--- a/MoinMoin/macro/GetVal.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/macro/GetVal.py	Sat Mar 12 15:28:21 2011 +0100
@@ -6,7 +6,7 @@
 """
 
 
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin.macro._base import MacroInlineBase
 
--- a/MoinMoin/macro/MailTo.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/macro/MailTo.py	Sat Mar 12 15:28:21 2011 +0100
@@ -7,7 +7,7 @@
 """
 
 
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin.util.tree import moin_page, xlink
 from MoinMoin.macro._base import MacroInlineBase
--- a/MoinMoin/macro/PagenameList.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/macro/PagenameList.py	Sat Mar 12 15:28:21 2011 +0100
@@ -10,7 +10,7 @@
 
 import re
 
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin.macro._base import MacroPageLinkListBase
 
--- a/MoinMoin/macro/RandomItem.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/macro/RandomItem.py	Sat Mar 12 15:28:21 2011 +0100
@@ -12,7 +12,7 @@
 import random
 random.seed()
 
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin.util.iri import Iri
 from MoinMoin.util.tree import moin_page, xlink
--- a/MoinMoin/script/account/create.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/script/account/create.py	Sat Mar 12 15:28:21 2011 +0100
@@ -7,8 +7,8 @@
 """
 
 
-from flask import flaskg
 from flask import current_app as app
+from flask import g as flaskg
 from flaskext.script import Command, Option
 
 from MoinMoin import user
--- a/MoinMoin/script/account/disable.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/script/account/disable.py	Sat Mar 12 15:28:21 2011 +0100
@@ -7,8 +7,8 @@
 """
 
 
-from flask import flaskg
 from flask import current_app as app
+from flask import g as flaskg
 from flaskext.script import Command, Option
 
 from MoinMoin import user
--- a/MoinMoin/script/account/resetpw.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/script/account/resetpw.py	Sat Mar 12 15:28:21 2011 +0100
@@ -8,8 +8,8 @@
 """
 
 
-from flask import flaskg
 from flask import current_app as app
+from flask import g as flaskg
 from flaskext.script import Command, Option
 
 from MoinMoin import user
--- a/MoinMoin/script/maint/create_item.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/script/maint/create_item.py	Sat Mar 12 15:28:21 2011 +0100
@@ -8,9 +8,10 @@
 """
 
 
-from flask import flaskg
 from flask import current_app as app
+from flask import g as flaskg
 from flaskext.script import Command, Option
+
 from MoinMoin.storage.error import ItemAlreadyExistsError, NoSuchItemError
 
 
--- a/MoinMoin/script/maint/set_meta.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/script/maint/set_meta.py	Sat Mar 12 15:28:21 2011 +0100
@@ -14,8 +14,8 @@
 from ast import literal_eval
 from shutil import copyfileobj
 
-from flask import flaskg
 from flask import current_app as app
+from flask import g as flaskg
 from flaskext.script import Command, Option
 
 from MoinMoin.script import fatal
--- a/MoinMoin/script/maint/xml.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/script/maint/xml.py	Sat Mar 12 15:28:21 2011 +0100
@@ -17,8 +17,8 @@
 
 import sys, time
 
-from flask import flaskg
 from flask import current_app as app
+from flask import g as flaskg
 from flaskext.script import Command, Option
 
 from MoinMoin.script import fatal
--- a/MoinMoin/security/__init__.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/security/__init__.py	Sat Mar 12 15:28:21 2011 +0100
@@ -20,8 +20,7 @@
 
 
 from flask import current_app as app
-
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin import user
 from MoinMoin.i18n import _, L_, N_
--- a/MoinMoin/security/_tests/test_security.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/security/_tests/test_security.py	Sat Mar 12 15:28:21 2011 +0100
@@ -11,8 +11,7 @@
 import py
 
 from flask import current_app as app
-
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin import security
 acliter = security.ACLStringIterator
--- a/MoinMoin/security/textcha.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/security/textcha.py	Sat Mar 12 15:28:21 2011 +0100
@@ -28,8 +28,8 @@
 logging = log.getLogger(__name__)
 
 from flask import current_app as app
+from flask import g as flaskg
 from flask import request
-from flask import flaskg
 
 import hashlib
 import hmac
--- a/MoinMoin/security/ticket.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/security/ticket.py	Sat Mar 12 15:28:21 2011 +0100
@@ -16,7 +16,7 @@
 logging = log.getLogger(__name__)
 
 from flask import current_app as app
-from flask import flaskg
+from flask import g as flaskg
 
 
 def createTicket(tm=None, **kw):
--- a/MoinMoin/storage/_tests/test_backends.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/storage/_tests/test_backends.py	Sat Mar 12 15:28:21 2011 +0100
@@ -18,7 +18,7 @@
 
 import py.test, re
 
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin.storage import Item, NewRevision
 from MoinMoin.storage.backends import memory
--- a/MoinMoin/storage/_tests/test_middleware_acl.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/storage/_tests/test_middleware_acl.py	Sat Mar 12 15:28:21 2011 +0100
@@ -10,7 +10,7 @@
 
 import py
 
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin.config import ACL
 from MoinMoin.storage.error import AccessDeniedError
--- a/MoinMoin/storage/_tests/test_serialization.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/storage/_tests/test_serialization.py	Sat Mar 12 15:28:21 2011 +0100
@@ -14,7 +14,7 @@
 
 from StringIO import StringIO
 
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin._tests import become_trusted, update_item
 from MoinMoin.storage.serialization import Entry, create_value_object, serialize, unserialize
--- a/MoinMoin/storage/backends/__init__.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/storage/backends/__init__.py	Sat Mar 12 15:28:21 2011 +0100
@@ -11,7 +11,7 @@
 """
 
 
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin.storage.serialization import unserialize
 from MoinMoin.storage.error import NoSuchItemError, RevisionAlreadyExistsError
--- a/MoinMoin/storage/backends/acl.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/storage/backends/acl.py	Sat Mar 12 15:28:21 2011 +0100
@@ -45,8 +45,7 @@
 from UserDict import DictMixin
 
 from flask import current_app as app
-
-from flask import flaskg
+from flask import g as flaskg
 
 from MoinMoin.security import AccessControlList
 
--- a/MoinMoin/themes/__init__.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/themes/__init__.py	Sat Mar 12 15:28:21 2011 +0100
@@ -11,7 +11,7 @@
 import urllib
 
 from flask import current_app as app
-from flask import flaskg
+from flask import g as flaskg
 from flask import url_for, request
 from flaskext.themes import get_theme, render_theme_template
 
--- a/MoinMoin/user.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/user.py	Sat Mar 12 15:28:21 2011 +0100
@@ -32,7 +32,8 @@
 from babel import parse_locale
 
 from flask import current_app as app
-from flask import flaskg, session, request, url_for
+from flask import g as flaskg
+from flask import session, request, url_for
 
 from MoinMoin import config, wikiutil
 from MoinMoin.i18n import _, L_, N_
--- a/MoinMoin/util/interwiki.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/util/interwiki.py	Sat Mar 12 15:28:21 2011 +0100
@@ -12,7 +12,7 @@
 
 from flask import current_app as app
 from flask import request
-from flask import flaskg
+from flask import g as flaskg
 
 import os.path
 
--- a/MoinMoin/util/monkeypatch.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/util/monkeypatch.py	Sat Mar 12 15:28:21 2011 +0100
@@ -30,10 +30,3 @@
 import sys
 posixemulation.sys = sys
 
-
-# flask patching -------------------------------------------------------------
-
-# creating a custom alias for the single-letter "g"
-import flask
-flask.flaskg = flask.g
-
--- a/MoinMoin/wikiutil.py	Sat Mar 12 15:10:04 2011 +0100
+++ b/MoinMoin/wikiutil.py	Sat Mar 12 15:28:21 2011 +0100
@@ -20,7 +20,7 @@
 logging = log.getLogger(__name__)
 
 from flask import current_app as app
-from flask import flaskg
+from flask import g as flaskg
 from flask import request
 
 from MoinMoin import config