From 7b9f9d1edb96aabab7e35818824b71efbdd4efb9 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Sat, 1 Dec 2012 23:35:52 +0100 Subject: Fix i18n in our browser We only ever served english pages since the switch to werkzeug's requests. Fix this by actually checking the accepted languages that our web browser sends and using that or falling back to english. This is not optimal, imaging our browser sends "klingon, de" as accepted languages and we happen to not have a klingon translation ready (a deficiency that should be corrected immediately anyway!!). We would then fall back to english rather than sending the sensible and pleasant German language which the user would understand. This will require more backend work though. Removing the gettext.find() in mg_globals.py. It looked in the wrong directory anyway (mediagoblin/translations) and as that does not exist, had always returned None without anyone noticing. Signed-off-by: Sebastian Spaeth --- mediagoblin/app.py | 1 - 1 file changed, 1 deletion(-) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 3a2d00f0..de421aca 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -134,7 +134,6 @@ class MediaGoblinApp(object): ## Compatibility webob -> werkzeug request.GET = request.args - request.accept_language = request.accept_languages request.accept = request.accept_mimetypes ## Routing / controller loading stuff -- cgit v1.2.3 From 6ef75af50ecd9b71a5d9455f616c421b1d84b732 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Sun, 2 Dec 2012 00:29:30 +0100 Subject: Honor user's browser language (#558) Previously we would attempt to satisfy the user's first language preference, immediately falling back to english if that was not possible. Now, we will get the best match of the user's preferred languages. This requires storing the available locales on app startup, so we have mg_globals.available_locales ready to compare them against the list of preferred user languages. Signed-off-by: Sebastian Spaeth --- mediagoblin/app.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index de421aca..876ded4e 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -31,7 +31,7 @@ from mediagoblin.mg_globals import setup_globals from mediagoblin.init.celery import setup_celery_from_config from mediagoblin.init.plugins import setup_plugins from mediagoblin.init import (get_jinja_loader, get_staticdirector, - setup_global_and_app_config, setup_workbench, setup_database, + setup_global_and_app_config, setup_locales, setup_workbench, setup_database, setup_storage, setup_beaker_cache) from mediagoblin.tools.pluginapi import PluginManager @@ -68,6 +68,9 @@ class MediaGoblinApp(object): # Setup other connections / useful objects ########################################## + # load all available locales + setup_locales() + # Set up plugins -- need to do this early so that plugins can # affect startup. _log.info("Setting up plugins.") -- cgit v1.2.3 From b745bb50d8a4c92b5adbbd6918262ff8c9cc9609 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Fri, 16 Nov 2012 10:25:50 +0100 Subject: Remove webob from render_to_response We were still using webob's Response objects for template rendering. Transition to werkzeug's Response object. One caveat was that it seemed to have used the default mimetype "text/plain" for all pages, so we override the default Response class, setting the default mime type to "text/html". Signed-off-by: Sebastian Spaeth --- mediagoblin/app.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 876ded4e..8bd2496f 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -193,7 +193,8 @@ class MediaGoblinApp(object): except NotFound as exc: return render_404(request)(environ, start_response) except HTTPException as exc: - # Support legacy webob.exc responses + # exceptions that match() is documented to return: + # MethodNotAllowed, RequestRedirect TODO: need to handle ??? return exc(environ, start_response) view_func = view_functions[endpoint] -- cgit v1.2.3 From 726896b62a87a88594cf3863f4bbfcaf84b2abb3 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Fri, 16 Nov 2012 11:36:04 +0100 Subject: Remove webob compatability Remove the aliases we provided for webob compatability as webob is now gone. Grepped the code base to check for occurences of the old parameters to be safe. Keep request.GET attribute as alias for request.args as it is often used and django is also using that attribute. Signed-off-by: Sebastian Spaeth --- mediagoblin/app.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 8bd2496f..9e06e52d 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -135,9 +135,8 @@ class MediaGoblinApp(object): def call_backend(self, environ, start_response): request = Request(environ) - ## Compatibility webob -> werkzeug + # Compatibility with django, use request.args preferrably request.GET = request.args - request.accept = request.accept_mimetypes ## Routing / controller loading stuff map_adapter = self.url_map.bind_to_environ(request.environ) -- cgit v1.2.3 From 573b4305cd077577b325d7b3ba9a65d3308e4061 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Fri, 21 Dec 2012 08:20:54 +0100 Subject: Don't dbug log every added plugin route It is killing testsuite output by drowning out all signals. It should be sufficient to state in the pluginmanager that routes have been added, if we need that kind of output. Signed-off-by: Sebastian Spaeth --- mediagoblin/app.py | 1 - 1 file changed, 1 deletion(-) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 9e06e52d..1a398bcd 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -96,7 +96,6 @@ class MediaGoblinApp(object): self.url_map = url_map for route in PluginManager().get_routes(): - _log.debug('adding plugin route: {0}'.format(route)) add_route(*route) # set up staticdirector tool -- cgit v1.2.3 From 785b287fcb42ac9130b222006097e3f68cec3543 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Sun, 23 Dec 2012 11:57:45 +0100 Subject: Provide tools.response.render_http_exception and use that After the webob->werkzeug transition, controller functions can raise werkzeug.HttpExceptions. We need to catch these in app.py when calling the controller and handle them, rendering the corresponding error Response() object. For consistency, we also want to allow meddleware functions to raise HttpExceptions (e.g. the csrf meddleware needs to complain about lack of cookies), so wrap the request and response parts of the meddleware too. Finally, the urlmap.match() can also raise HttpExceptions, so we give it the same treatment (render_http_exception). I am not sure, if we do not need to handle the Redirect exception there in any different way though... The new function render_http_exception makes use of the render_error infrastructure to return a nicely templated error page. It also checks if the stock error messages was used in cases where we have localizations (403, 404) and use those. It is now possible to do things like "raise Forbidden(_('You suckr'))" or raise NotFound(_('where is my left show again')) if you want to return customized error messages to the user. Signed-off-by: Sebastian Spaeth --- mediagoblin/app.py | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 1a398bcd..d1f4cab7 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -24,7 +24,7 @@ from werkzeug.exceptions import HTTPException, NotFound from mediagoblin import meddleware, __version__ from mediagoblin.tools import common, translate, template -from mediagoblin.tools.response import render_404 +from mediagoblin.tools.response import render_http_exception from mediagoblin.tools.theme import register_themes from mediagoblin.tools import request as mg_request from mediagoblin.mg_globals import setup_globals @@ -188,12 +188,11 @@ class MediaGoblinApp(object): try: endpoint, url_values = map_adapter.match() request.matchdict = url_values - except NotFound as exc: - return render_404(request)(environ, start_response) except HTTPException as exc: - # exceptions that match() is documented to return: - # MethodNotAllowed, RequestRedirect TODO: need to handle ??? - return exc(environ, start_response) + # Stop and render exception + return render_http_exception( + request, exc, + exc.get_description(environ))(environ, start_response) view_func = view_functions[endpoint] @@ -209,19 +208,32 @@ class MediaGoblinApp(object): controller = view_func # pass the request through our meddleware classes - for m in self.meddleware: - response = m.process_request(request, controller) - if response is not None: - return response(environ, start_response) + try: + for m in self.meddleware: + response = m.process_request(request, controller) + if response is not None: + return response(environ, start_response) + except HTTPException as e: + return render_http_exception( + request, e, + e.get_description(environ))(environ, start_response) request.start_response = start_response - # get the response from the controller - response = controller(request) + # get the Http response from the controller + try: + response = controller(request) + except HTTPException as e: + response = render_http_exception( + request, e, e.get_description(environ)) - # pass the response through the meddleware - for m in self.meddleware[::-1]: - m.process_response(request, response) + # pass the response through the meddlewares + try: + for m in self.meddleware[::-1]: + m.process_response(request, response) + except HTTPException as e: + response = render_http_exeption( + request, e, e.get_description(environ)) return response(environ, start_response) -- cgit v1.2.3 From 48cf435d718b47e33cb98b048e5b58d79a46b486 Mon Sep 17 00:00:00 2001 From: Elrond Date: Sat, 1 Dec 2012 21:36:18 +0100 Subject: Refactor routing in app.py. Move some things out of app.py into functions in routing.py. This makes app.py a bit more readable and allows us to rewrite routing. --- mediagoblin/app.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index d1f4cab7..207e9d2c 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -17,7 +17,7 @@ import os import logging -from mediagoblin.routing import url_map, view_functions, add_route +from mediagoblin.routing import get_url_map, endpoint_to_controller from werkzeug.wrappers import Request from werkzeug.exceptions import HTTPException, NotFound @@ -93,10 +93,7 @@ class MediaGoblinApp(object): self.public_store, self.queue_store = setup_storage() # set up routing - self.url_map = url_map - - for route in PluginManager().get_routes(): - add_route(*route) + self.url_map = get_url_map() # set up staticdirector tool self.staticdirector = get_staticdirector(app_config) @@ -194,18 +191,7 @@ class MediaGoblinApp(object): request, exc, exc.get_description(environ))(environ, start_response) - view_func = view_functions[endpoint] - - _log.debug('endpoint: {0} view_func: {1}'.format( - endpoint, - view_func)) - - # import the endpoint, or if it's already a callable, call that - if isinstance(view_func, unicode) \ - or isinstance(view_func, str): - controller = common.import_component(view_func) - else: - controller = view_func + controller = endpoint_to_controller(endpoint) # pass the request through our meddleware classes try: -- cgit v1.2.3 From 3d9143323019e0793451eac60eef8e55c09f6c47 Mon Sep 17 00:00:00 2001 From: Elrond Date: Sun, 16 Dec 2012 00:50:20 +0100 Subject: Move things from routing.py to tools/routing.py This stops a cyclic import. Move add_route, mount and endpoint_to_controller into tools/routing.py and change all callers. --- mediagoblin/app.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 207e9d2c..ff64f65c 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -17,7 +17,8 @@ import os import logging -from mediagoblin.routing import get_url_map, endpoint_to_controller +from mediagoblin.routing import get_url_map +from mediagoblin.tools.routing import endpoint_to_controller from werkzeug.wrappers import Request from werkzeug.exceptions import HTTPException, NotFound -- cgit v1.2.3 From 05501c5742c85d0e2c855a02800d1f50f9df6c3d Mon Sep 17 00:00:00 2001 From: Elrond Date: Sun, 16 Dec 2012 00:45:57 +0100 Subject: Rewrite routing using new MGRoute class MGRoute subclasses Rule(): Rule doesn't have a way to tag extra data, like the controller function, we need. So MGRoute has a new attribute .gmg_controller, which holds this. Rewrite everything to use this new Rule variant and drop all the other stuff that mapped endpoints to controller functions, mostly. --- mediagoblin/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index ff64f65c..936a354f 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -184,7 +184,7 @@ class MediaGoblinApp(object): mg_request.setup_user_in_request(request) try: - endpoint, url_values = map_adapter.match() + found_rule, url_values = map_adapter.match(return_rule=True) request.matchdict = url_values except HTTPException as exc: # Stop and render exception @@ -192,7 +192,7 @@ class MediaGoblinApp(object): request, exc, exc.get_description(environ))(environ, start_response) - controller = endpoint_to_controller(endpoint) + controller = endpoint_to_controller(found_rule) # pass the request through our meddleware classes try: -- cgit v1.2.3 From bc142abc5592975c08319416d0af12c108504887 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Thu, 29 Nov 2012 17:23:28 +0100 Subject: RIP out mongo Since sqlalchemy is providing our database abstraction and we have moved away from Mongo as the underlying database, it is now time to simplify things and rip out mongo. This provides the bulk of the changes, and can stand on its own. There are some followup tasks that can be done, such as removing now unneeded abstraction layers, e.g. db.sql.fake.py --- mediagoblin/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 936a354f..c1636693 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -78,7 +78,7 @@ class MediaGoblinApp(object): setup_plugins() # Set up the database - self.connection, self.db = setup_database() + self.db = setup_database() # Register themes self.theme_registry, self.current_theme = register_themes(app_config) -- cgit v1.2.3 From fd61aac7c719a875ecdcc2e43d7dcf561bc28eca Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Tue, 15 Jan 2013 16:52:22 +0100 Subject: Unbreak 301 responses The move to werkzeug routing went pretty smooth, but one thing was broken by accident: URLs without final slash result in a 301 werkzeug.routing.RequestRedirect response. We displayed it as a generic error page rather than actually sending the redirect. Do that. One thing it does though is to skip all meddlewares, which should be OK for a 301 response, but might need rework if we decide otherwise. With this, 301 responses with lacking final slash are unbroken again. Signed-off-by: Sebastian Spaeth --- mediagoblin/app.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index c1636693..10fbf4a3 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -22,6 +22,7 @@ from mediagoblin.tools.routing import endpoint_to_controller from werkzeug.wrappers import Request from werkzeug.exceptions import HTTPException, NotFound +from werkzeug.routing import RequestRedirect from mediagoblin import meddleware, __version__ from mediagoblin.tools import common, translate, template @@ -186,6 +187,9 @@ class MediaGoblinApp(object): try: found_rule, url_values = map_adapter.match(return_rule=True) request.matchdict = url_values + except RequestRedirect as response: + # Deal with 301 responses eg due to missing final slash + return response(environ, start_response) except HTTPException as exc: # Stop and render exception return render_http_exception( -- cgit v1.2.3 From e5e2c5e7aa2c882ea02ca5eaa63a1e53d15946e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Veres-Szentkir=C3=A1lyi?= Date: Thu, 21 Feb 2013 10:48:18 +0100 Subject: removed unused import NotFound --- mediagoblin/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 10fbf4a3..607d599b 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -21,7 +21,7 @@ from mediagoblin.routing import get_url_map from mediagoblin.tools.routing import endpoint_to_controller from werkzeug.wrappers import Request -from werkzeug.exceptions import HTTPException, NotFound +from werkzeug.exceptions import HTTPException from werkzeug.routing import RequestRedirect from mediagoblin import meddleware, __version__ -- cgit v1.2.3 From f3f530286ff576a3120e29f734aff0b7b7fe882c Mon Sep 17 00:00:00 2001 From: Joar Wandborg Date: Sun, 3 Mar 2013 02:32:03 +0100 Subject: Updated raven plugin - Added wrap_wsgi, celery_setup, celery_logging_setup hooks - Updated raven plugin docs - Updated production considerations docs - Added raven logging setup --- mediagoblin/app.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 607d599b..bb6be4d4 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -253,4 +253,7 @@ def paste_app_factory(global_config, **app_config): mgoblin_app = MediaGoblinApp(mediagoblin_config) + for callable_hook in PluginManager().get_hook_callables('wrap_wsgi'): + mgoblin_app = callable_hook(mgoblin_app) + return mgoblin_app -- cgit v1.2.3 From 5907154a593bf5fc02c1e0fbc8afe683ac7d3602 Mon Sep 17 00:00:00 2001 From: Elrond Date: Fri, 22 Mar 2013 18:46:47 +0100 Subject: Basic itsdangerous infrastructure. Implement the basic infrastructure for using itsdangerous in mediagoblin. Usage instructions will follow. --- mediagoblin/app.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index bb6be4d4..515b5b66 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -36,6 +36,7 @@ from mediagoblin.init import (get_jinja_loader, get_staticdirector, setup_global_and_app_config, setup_locales, setup_workbench, setup_database, setup_storage, setup_beaker_cache) from mediagoblin.tools.pluginapi import PluginManager +from mediagoblin.tools.crypto import setup_crypto _log = logging.getLogger(__name__) @@ -66,6 +67,8 @@ class MediaGoblinApp(object): # Open and setup the config global_config, app_config = setup_global_and_app_config(config_path) + setup_crypto() + ########################################## # Setup other connections / useful objects ########################################## -- cgit v1.2.3 From c7424612d7c0447373dce8d69aa5af03aebe08dc Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Sun, 24 Mar 2013 14:44:41 -0400 Subject: Back sessions with It's Dangerous. This is a contribution to #668. --- mediagoblin/app.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 515b5b66..fe8e8c4b 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -25,7 +25,7 @@ from werkzeug.exceptions import HTTPException from werkzeug.routing import RequestRedirect from mediagoblin import meddleware, __version__ -from mediagoblin.tools import common, translate, template +from mediagoblin.tools import common, session, translate, template from mediagoblin.tools.response import render_http_exception from mediagoblin.tools.theme import register_themes from mediagoblin.tools import request as mg_request @@ -160,7 +160,8 @@ class MediaGoblinApp(object): ## Attach utilities to the request object # Do we really want to load this via middleware? Maybe? - request.session = request.environ['beaker.session'] + session_manager = session.SessionManager() + request.session = session_manager.load_session_from_cookie(request) # Attach self as request.app # Also attach a few utilities from request.app for convenience? request.app = self @@ -229,6 +230,8 @@ class MediaGoblinApp(object): response = render_http_exeption( request, e, e.get_description(environ)) + session_manager.save_session_to_cookie(request.session, response) + return response(environ, start_response) def __call__(self, environ, start_response): -- cgit v1.2.3 From 9e1fa2396fa4d340e3bcf01116cd1e2b6e5dee51 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Sun, 24 Mar 2013 15:10:08 -0400 Subject: Remove beaker stuff from the code. This is all obsoleted by It's Dangerous. --- mediagoblin/app.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index fe8e8c4b..2c772fe1 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -34,7 +34,7 @@ from mediagoblin.init.celery import setup_celery_from_config from mediagoblin.init.plugins import setup_plugins from mediagoblin.init import (get_jinja_loader, get_staticdirector, setup_global_and_app_config, setup_locales, setup_workbench, setup_database, - setup_storage, setup_beaker_cache) + setup_storage) from mediagoblin.tools.pluginapi import PluginManager from mediagoblin.tools.crypto import setup_crypto @@ -103,9 +103,6 @@ class MediaGoblinApp(object): # set up staticdirector tool self.staticdirector = get_staticdirector(app_config) - # set up caching - self.cache = setup_beaker_cache() - # Setup celery, if appropriate if setup_celery and not app_config.get('celery_setup_elsewhere'): if os.environ.get('CELERY_ALWAYS_EAGER', 'false').lower() == 'true': -- cgit v1.2.3 From b0ee3aae91fa49b25b84dce20931e970639d17fe Mon Sep 17 00:00:00 2001 From: Elrond Date: Tue, 9 Apr 2013 22:49:11 +0200 Subject: Make session cookies more secure. 1. Our session cookies only need to be available to http, so mark them appropiately. 2. Send the cookie to the subpath for mediagoblin. And instantiate a session manager on the app, once. --- mediagoblin/app.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 2c772fe1..1137c0d7 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -73,6 +73,9 @@ class MediaGoblinApp(object): # Setup other connections / useful objects ########################################## + # Setup Session Manager, not needed in celery + self.session_manager = session.SessionManager() + # load all available locales setup_locales() @@ -157,7 +160,7 @@ class MediaGoblinApp(object): ## Attach utilities to the request object # Do we really want to load this via middleware? Maybe? - session_manager = session.SessionManager() + session_manager = self.session_manager request.session = session_manager.load_session_from_cookie(request) # Attach self as request.app # Also attach a few utilities from request.app for convenience? @@ -227,7 +230,8 @@ class MediaGoblinApp(object): response = render_http_exeption( request, e, e.get_description(environ)) - session_manager.save_session_to_cookie(request.session, response) + session_manager.save_session_to_cookie(request.session, + request, response) return response(environ, start_response) -- cgit v1.2.3 From 6a28bc4e87de920dbd97e078dc8f4876c8d52cfc Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Wed, 17 Apr 2013 10:03:33 -0500 Subject: Fixing typo in calling render_http_exception --- mediagoblin/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 1137c0d7..2c88e916 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -227,7 +227,7 @@ class MediaGoblinApp(object): for m in self.meddleware[::-1]: m.process_response(request, response) except HTTPException as e: - response = render_http_exeption( + response = render_http_exception( request, e, e.get_description(environ)) session_manager.save_session_to_cookie(request.session, -- cgit v1.2.3 From c5d8d30182731f8e689574e096f663dcf665360d Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Fri, 19 Apr 2013 16:51:14 -0500 Subject: removing old callable utilities and porting stuff over. --- mediagoblin/app.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 2c88e916..bf0e0f13 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -35,7 +35,7 @@ from mediagoblin.init.plugins import setup_plugins from mediagoblin.init import (get_jinja_loader, get_staticdirector, setup_global_and_app_config, setup_locales, setup_workbench, setup_database, setup_storage) -from mediagoblin.tools.pluginapi import PluginManager +from mediagoblin.tools.pluginapi import PluginManager, hook_transform from mediagoblin.tools.crypto import setup_crypto @@ -259,8 +259,6 @@ def paste_app_factory(global_config, **app_config): raise IOError("Usable mediagoblin config not found.") mgoblin_app = MediaGoblinApp(mediagoblin_config) - - for callable_hook in PluginManager().get_hook_callables('wrap_wsgi'): - mgoblin_app = callable_hook(mgoblin_app) + mgoblin_app = hook_transform('wrap_wsgi', mgoblin_app) return mgoblin_app -- cgit v1.2.3 From 3810309443899e92d640fb0c893018ef82b786ee Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Wed, 8 May 2013 14:35:31 -0500 Subject: The beginning of context hooks. Not the working solution, but getting there conceptually. Basically we'll have a key with the view and the template as a tuple which is the context hook that anyone can attach to. However, some changes have still to be made: - The unit test doesn't work yet and contains a set_trace ;) - We'll probably switch the "view" component from being the callable to the "urlgen"'able name per Elrond's suggestion - Found a bug in unit tests related to running custom apps for different configs... hm. I need to fix this! Nonetheless, making progress. This commit sponsored by... wait a minute... Christopher Webber?! --- mediagoblin/app.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index bf0e0f13..dc2900a9 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -201,6 +201,9 @@ class MediaGoblinApp(object): exc.get_description(environ))(environ, start_response) controller = endpoint_to_controller(found_rule) + # Make a reference to the controller on the request... + # used for lazy context modification + request.controller = controller # pass the request through our meddleware classes try: -- cgit v1.2.3 From 98dacfe67e40eb3c575b2fb9a5a80ced3e284ddc Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Fri, 10 May 2013 20:26:55 -0500 Subject: Use the controller's symbolic/lookup name as part of the key for context hooks This commit sponsored by David Collins. Thank you! --- mediagoblin/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index dc2900a9..3ebaa45b 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -201,9 +201,9 @@ class MediaGoblinApp(object): exc.get_description(environ))(environ, start_response) controller = endpoint_to_controller(found_rule) - # Make a reference to the controller on the request... + # Make a reference to the controller's symbolic name on the request... # used for lazy context modification - request.controller = controller + request.controller_name = found_rule.endpoint # pass the request through our meddleware classes try: -- cgit v1.2.3 From f7a5c7c78c6dcf3dcb3b81efbedc9a333df49fb7 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Tue, 14 May 2013 14:24:27 -0500 Subject: Fully working context hooks, both template/view and global level, with tests Needs documentation though... that's coming next :) This commit sponsored by Luca Tius. Thanks Luca! --- mediagoblin/app.py | 1 + 1 file changed, 1 insertion(+) (limited to 'mediagoblin/app.py') diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 3ebaa45b..1984ce77 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -188,6 +188,7 @@ class MediaGoblinApp(object): mg_request.setup_user_in_request(request) + request.controller_name = None try: found_rule, url_values = map_adapter.match(return_rule=True) request.matchdict = url_values -- cgit v1.2.3