diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-08-20 15:00:25 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-08-20 15:00:25 -0500 |
commit | 3d0557bf25683c26ec2b6de041d53fe5a0c6255c (patch) | |
tree | d1127a31cec1f13bac5bbe6a14173f5688280e6c /mediagoblin/app.py | |
parent | 0161aa920da71c8507854a9cc4e3406afb737bce (diff) | |
download | mediagoblin-3d0557bf25683c26ec2b6de041d53fe5a0c6255c.tar.lz mediagoblin-3d0557bf25683c26ec2b6de041d53fe5a0c6255c.tar.xz mediagoblin-3d0557bf25683c26ec2b6de041d53fe5a0c6255c.zip |
Change the ordering of the app's __call__ method (attach things to request first)
This will make it easier for us to call something like a 404 page rendering method
before the matching check is done.
Diffstat (limited to 'mediagoblin/app.py')
-rw-r--r-- | mediagoblin/app.py | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/mediagoblin/app.py b/mediagoblin/app.py index c1ee3d77..96a7ad61 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -101,6 +101,23 @@ class MediaGoblinApp(object): ## Routing / controller loading stuff route_match = self.routing.match(path_info) + ## Attach utilities to the request object + request.matchdict = route_match + request.urlgen = routes.URLGenerator(self.routing, environ) + # Do we really want to load this via middleware? Maybe? + request.session = request.environ['beaker.session'] + # Attach self as request.app + # Also attach a few utilities from request.app for convenience? + request.app = self + request.locale = util.get_locale_from_request(request) + + request.template_env = util.get_jinja_env( + self.template_loader, request.locale) + request.db = self.db + request.staticdirect = self.staticdirector + + util.setup_user_in_request(request) + # No matching page? if route_match is None: # Try to do see if we have a match with a trailing slash @@ -121,23 +138,6 @@ class MediaGoblinApp(object): controller = util.import_component(route_match['controller']) request.start_response = start_response - ## Attach utilities to the request object - request.matchdict = route_match - request.urlgen = routes.URLGenerator(self.routing, environ) - # Do we really want to load this via middleware? Maybe? - request.session = request.environ['beaker.session'] - # Attach self as request.app - # Also attach a few utilities from request.app for convenience? - request.app = self - request.locale = util.get_locale_from_request(request) - - request.template_env = util.get_jinja_env( - self.template_loader, request.locale) - request.db = self.db - request.staticdirect = self.staticdirector - - util.setup_user_in_request(request) - return controller(request)(environ, start_response) |