From: Christopher Allan Webber Date: Sun, 8 Apr 2012 14:54:32 +0000 (-0500) Subject: Allow users to pass callables in as controllers, not just import paths X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=8a0d35e72aa50ca9add0f1e47e40ef7c8c5de039;p=mediagoblin.git Allow users to pass callables in as controllers, not just import paths --- 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: