X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=mediagoblin%2Fapp.py;h=0a57c09101e7db3944b59f10f594ec93aaf6fdb9;hb=ff6933fa4c63611f8e3d512d6608767cbdece6ec;hp=04eb2acc8fa2de3efb1f0c85adea3f02710aa1dd;hpb=ea5a5b15a3d552eaefc4cf220ed155af06f7c8f7;p=mediagoblin.git diff --git a/mediagoblin/app.py b/mediagoblin/app.py index 04eb2acc..0a57c091 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -1,5 +1,5 @@ # GNU MediaGoblin -- federated, autonomous media hosting -# Copyright (C) 2011 MediaGoblin contributors. See AUTHORS. +# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -16,11 +16,12 @@ import os import urllib +import logging import routes from webob import Request, exc -from mediagoblin import routing, meddleware +from mediagoblin import routing, meddleware, __version__ from mediagoblin.tools import common, translate, template from mediagoblin.tools.response import render_404 from mediagoblin.tools import request as mg_request @@ -31,6 +32,9 @@ from mediagoblin.init import (get_jinja_loader, get_staticdirector, setup_storage, setup_beaker_cache) +_log = logging.getLogger(__name__) + + class MediaGoblinApp(object): """ WSGI application of MediaGoblin @@ -47,6 +51,7 @@ class MediaGoblinApp(object): (Note: setting 'celery_setup_elsewhere' also disables setting up celery.) """ + _log.info("GNU MediaGoblin %s main server starting", __version__) ############## # Setup config ############## @@ -122,6 +127,11 @@ class MediaGoblinApp(object): # The other option would be: # request.full_path = environ["SCRIPT_URL"] + # Fix up environ for urlgen + # See bug: https://bitbucket.org/bbangert/routes/issue/55/cache_hostinfo-breaks-on-https-off + if environ.get('HTTPS', '').lower() == 'off': + environ.pop('HTTPS') + ## Attach utilities to the request object request.matchdict = route_match request.urlgen = routes.URLGenerator(self.routing, environ) @@ -174,6 +184,14 @@ class MediaGoblinApp(object): for m in self.meddleware[::-1]: m.process_response(request, response) + # Reset the sql session, so that the next request + # gets a fresh session + try: + self.db.reset_after_request() + except TypeError: + # We're still on mongo + pass + return response(environ, start_response)