diff --git a/pylons_app/config/middleware.py b/pylons_app/config/middleware.py --- a/pylons_app/config/middleware.py +++ b/pylons_app/config/middleware.py @@ -8,10 +8,11 @@ from pylons import config from pylons.middleware import ErrorHandler, StatusCodeRedirect from pylons.wsgiapp import PylonsApp from routes.middleware import RoutesMiddleware - from pylons_app.config.environment import load_environment -def make_app(global_conf, full_stack = True, static_files = True, **app_conf): + + +def make_app(global_conf, full_stack = True, **app_conf): """Create a Pylons WSGI application and return it ``global_conf`` @@ -19,14 +20,10 @@ def make_app(global_conf, full_stack = T the [DEFAULT] section of the Paste ini file. ``full_stack`` - Whether this application provides a full WSGI stack (by default, - meaning it handles its own exceptions and errors). Disable - full_stack when this application is "managed" by another WSGI - middleware. - - ``static_files`` - Whether this application serves its own static files; disable - when another web server is responsible for serving them. + Whether or not this application provides a full WSGI stack (by + default, meaning it handles its own exceptions and errors). + Disable full_stack when this application is "managed" by + another WSGI middleware. ``app_conf`` The application's local configuration. Normally specified in @@ -40,12 +37,10 @@ def make_app(global_conf, full_stack = T # The Pylons WSGI app app = PylonsApp() + # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) + # Routing/Session/Cache Middleware app = RoutesMiddleware(app, config['routes.map']) - app = SessionMiddleware(app, config) - app = CacheMiddleware(app, config) - - # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) if asbool(full_stack): # Handle Python exceptions @@ -61,14 +56,9 @@ def make_app(global_conf, full_stack = T # Establish the Registry for this application app = RegistryManager(app) - if asbool(static_files): - # Serve static files - static_app = StaticURLParser(config['pylons.paths']['static_files']) - app = Cascade([static_app, app]) + # Static files (If running in production, and Apache or another web + # server is handling this static content, remove the following 3 lines) + static_app = StaticURLParser(config['pylons.paths']['static_files']) + app = Cascade([static_app, app]) + return app - #dozer debug - if asbool(config['debug']): - from dozer import Logview - app = Logview(app, config) - - return app