From: Christopher Allan Webber Date: Fri, 25 Nov 2011 18:13:56 +0000 (-0600) Subject: Rename MediaGoblin middleware to meddleware to avoid confusion w/ wsgi middleware X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ce5ae8da19707019cd62d42533e591d71071f4fe;p=mediagoblin.git Rename MediaGoblin middleware to meddleware to avoid confusion w/ wsgi middleware hehehehehe, "meddleware" --- diff --git a/mediagoblin/app.py b/mediagoblin/app.py index ce4b0bec..aafadd97 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -20,7 +20,7 @@ import urllib import routes from webob import Request, exc -from mediagoblin import routing, middleware +from mediagoblin import routing, meddleware from mediagoblin.tools import common, translate, template from mediagoblin.tools.response import render_404 from mediagoblin.tools import request as mg_request @@ -100,15 +100,15 @@ class MediaGoblinApp(object): # matters in always eager mode :) setup_workbench() - # instantiate application middleware - self.middleware = [common.import_component(m)(self) - for m in middleware.ENABLED_MIDDLEWARE] + # instantiate application meddleware + self.meddleware = [common.import_component(m)(self) + for m in meddleware.ENABLED_MEDDLEWARE] def __call__(self, environ, start_response): request = Request(environ) - # pass the request through our middleware classes - for m in self.middleware: + # pass the request through our meddleware classes + for m in self.meddleware: response = m.process_request(request) if response is not None: return response(environ, start_response) @@ -169,8 +169,8 @@ class MediaGoblinApp(object): # get the response from the controller response = controller(request) - # pass the response through the middleware - for m in self.middleware[::-1]: + # pass the response through the meddleware + for m in self.meddleware[::-1]: m.process_response(request, response) return response(environ, start_response) diff --git a/mediagoblin/middleware/__init__.py b/mediagoblin/meddleware/__init__.py similarity index 86% rename from mediagoblin/middleware/__init__.py rename to mediagoblin/meddleware/__init__.py index 05325ee5..3addc937 100644 --- a/mediagoblin/middleware/__init__.py +++ b/mediagoblin/meddleware/__init__.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -ENABLED_MIDDLEWARE = ( - 'mediagoblin.middleware.noop:NoOpMiddleware', - 'mediagoblin.middleware.csrf:CsrfMiddleware', +ENABLED_MEDDLEWARE = ( + 'mediagoblin.meddleware.noop:NoOpMeddleware', + 'mediagoblin.meddleware.csrf:CsrfMeddleware', ) diff --git a/mediagoblin/middleware/csrf.py b/mediagoblin/meddleware/csrf.py similarity index 98% rename from mediagoblin/middleware/csrf.py rename to mediagoblin/meddleware/csrf.py index 8275c18e..051afe58 100644 --- a/mediagoblin/middleware/csrf.py +++ b/mediagoblin/meddleware/csrf.py @@ -47,8 +47,8 @@ def render_csrf_form_token(request): return form.csrf_token -class CsrfMiddleware(object): - """CSRF Protection Middleware +class CsrfMeddleware(object): + """CSRF Protection Meddleware Adds a CSRF Cookie to responses and verifies that it is present and matches the form token for non-safe requests. diff --git a/mediagoblin/middleware/noop.py b/mediagoblin/meddleware/noop.py similarity index 96% rename from mediagoblin/middleware/noop.py rename to mediagoblin/meddleware/noop.py index 820b5d9e..d11a5b9e 100644 --- a/mediagoblin/middleware/noop.py +++ b/mediagoblin/meddleware/noop.py @@ -15,7 +15,7 @@ # along with this program. If not, see . -class NoOpMiddleware(object): +class NoOpMeddleware(object): def __init__(self, mg_app): self.app = mg_app diff --git a/mediagoblin/tests/tools.py b/mediagoblin/tests/tools.py index 420d9ba8..1a26c6e9 100644 --- a/mediagoblin/tests/tools.py +++ b/mediagoblin/tests/tools.py @@ -50,9 +50,9 @@ $ CELERY_CONFIG_MODULE=mediagoblin.init.celery.from_tests ./bin/nosetests""" class BadCeleryEnviron(Exception): pass -class TestingMiddleware(object): +class TestingMeddleware(object): """ - Middleware for the Unit tests + Meddleware for the Unit tests It might make sense to perform some tests on all requests/responses. Or prepare them in a special @@ -60,7 +60,7 @@ class TestingMiddleware(object): for being valid html *after* being rendered. This module is getting inserted at the front of the - middleware list, which means: requests are handed here + meddleware list, which means: requests are handed here first, responses last. So this wraps up the "normal" app. @@ -149,11 +149,11 @@ def get_test_app(dump_old_app=True): test_app = loadapp( 'config:' + TEST_SERVER_CONFIG) - # Insert the TestingMiddleware, which can do some + # Insert the TestingMeddleware, which can do some # sanity checks on every request/response. # Doing it this way is probably not the cleanest way. # We'll fix it, when we have plugins! - mg_globals.app.middleware.insert(0, TestingMiddleware(mg_globals.app)) + mg_globals.app.meddleware.insert(0, TestingMeddleware(mg_globals.app)) app = TestApp(test_app) MGOBLIN_APP = app diff --git a/mediagoblin/tools/template.py b/mediagoblin/tools/template.py index 0986761b..f48b7c2e 100644 --- a/mediagoblin/tools/template.py +++ b/mediagoblin/tools/template.py @@ -21,7 +21,7 @@ from mediagoblin import mg_globals from mediagoblin import messages from mediagoblin.tools import common from mediagoblin.tools.translate import setup_gettext -from mediagoblin.middleware.csrf import render_csrf_form_token +from mediagoblin.meddleware.csrf import render_csrf_form_token SETUP_JINJA_ENVS = {}