diff options
author | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-04-17 09:43:03 -0500 |
---|---|---|
committer | Christopher Allan Webber <cwebber@dustycloud.org> | 2011-04-17 09:43:03 -0500 |
commit | cb8ea0fe3f44f21c13e16f8d6363f56f31c52b27 (patch) | |
tree | 6ae0bb4be1a7aef42c4d2f34adb8c2f3c5cff160 /mediagoblin/app.py | |
parent | 904f61c2988af2e27701a9ea47140abab12624aa (diff) | |
download | mediagoblin-cb8ea0fe3f44f21c13e16f8d6363f56f31c52b27.tar.lz mediagoblin-cb8ea0fe3f44f21c13e16f8d6363f56f31c52b27.tar.xz mediagoblin-cb8ea0fe3f44f21c13e16f8d6363f56f31c52b27.zip |
Moved app.load_controller -> util.import_component and added tests.
Diffstat (limited to 'mediagoblin/app.py')
-rw-r--r-- | mediagoblin/app.py | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 195d4792..0316b43c 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -14,10 +14,8 @@ # 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/>. -import sys import urllib -from beaker.middleware import SessionMiddleware import routes import mongokit from webob import Request, exc @@ -29,14 +27,6 @@ class Error(Exception): pass class ImproperlyConfigured(Error): pass -def load_controller(string): - module_name, func_name = string.split(':', 1) - __import__(module_name) - module = sys.modules[module_name] - func = getattr(module, func_name) - return func - - class MediaGoblinApp(object): """ Really basic wsgi app using routes and WebOb. @@ -71,7 +61,7 @@ class MediaGoblinApp(object): # Okay, no matches. 404 time! return exc.HTTPNotFound()(environ, start_response) - controller = load_controller(route_match['controller']) + controller = util.import_component(route_match['controller']) request.start_response = start_response request.matchdict = route_match @@ -87,9 +77,13 @@ class MediaGoblinApp(object): def paste_app_factory(global_config, **kw): + # Get the database connection connection = mongokit.Connection( kw.get('db_host'), kw.get('db_port')) + # Set up the storage systems. + ## TODO: allow for extra storage systems that aren't just + ## BasicFileStorage. mgoblin_app = MediaGoblinApp( connection, kw.get('db_name', 'mediagoblin'), user_template_path=kw.get('local_templates')) |