From 8a0d35e72aa50ca9add0f1e47e40ef7c8c5de039 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Sun, 8 Apr 2012 09:54:32 -0500 Subject: [PATCH] Allow users to pass callables in as controllers, not just import paths --- mediagoblin/app.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mediagoblin/app.py b/mediagoblin/app.py index b7ca092d..99c7de76 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -167,7 +167,13 @@ class MediaGoblinApp(object): request.matchdict = {} # in case our template expects it return render_404(request)(environ, start_response) - controller = common.import_component(route_match['controller']) + # import the controller, or if it's already a callable, call that + route_controller = route_match['controller'] + if isinstance(route_controller, unicode) \ + or isinstance(route_controller, str): + controller = common.import_component(route_match['controller']) + else: + controller = route_match['controller'] # pass the request through our meddleware classes for m in self.meddleware: