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
# 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)
# 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)
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-ENABLED_MIDDLEWARE = (
- 'mediagoblin.middleware.noop:NoOpMiddleware',
- 'mediagoblin.middleware.csrf:CsrfMiddleware',
+ENABLED_MEDDLEWARE = (
+ 'mediagoblin.meddleware.noop:NoOpMeddleware',
+ 'mediagoblin.meddleware.csrf:CsrfMeddleware',
)
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.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-class NoOpMiddleware(object):
+class NoOpMeddleware(object):
def __init__(self, mg_app):
self.app = mg_app
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
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.
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
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 = {}