# 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
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
setup_storage, setup_beaker_cache)
+_log = logging.getLogger(__name__)
+
+
class MediaGoblinApp(object):
"""
WSGI application of MediaGoblin
(Note: setting 'celery_setup_elsewhere' also disables
setting up celery.)
"""
+ _log.info("GNU MediaGoblin %s main server starting", __version__)
##############
# Setup config
##############
# 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)
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)