##// END OF EJS Templates
fixed bug in middleware config
marcink -
r269:183c0640 default
parent child Browse files
Show More
@@ -1,75 +1,75
1 1 """Pylons middleware initialization"""
2 2 from beaker.middleware import SessionMiddleware
3 3 from paste.cascade import Cascade
4 4 from paste.registry import RegistryManager
5 5 from paste.urlparser import StaticURLParser
6 6 from paste.deploy.converters import asbool
7 7 from pylons.middleware import ErrorHandler, StatusCodeRedirect
8 8 from pylons.wsgiapp import PylonsApp
9 9 from routes.middleware import RoutesMiddleware
10 10 from pylons_app.lib.middleware.simplehg import SimpleHg
11 11 from pylons_app.lib.middleware.https_fixup import HttpsFixup
12 12 from pylons_app.config.environment import load_environment
13 13
14 14 def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
15 15 """Create a Pylons WSGI application and return it
16 16
17 17 ``global_conf``
18 18 The inherited configuration for this application. Normally from
19 19 the [DEFAULT] section of the Paste ini file.
20 20
21 21 ``full_stack``
22 22 Whether or not this application provides a full WSGI stack (by
23 23 default, meaning it handles its own exceptions and errors).
24 24 Disable full_stack when this application is "managed" by
25 25 another WSGI middleware.
26 26
27 27 ``app_conf``
28 28 The application's local configuration. Normally specified in
29 29 the [app:<name>] section of the Paste ini file (where <name>
30 30 defaults to main).
31 31
32 32 """
33 33 # Configure the Pylons environment
34 34 config = load_environment(global_conf, app_conf)
35 35
36 36
37 37 # The Pylons WSGI app
38 38 app = PylonsApp(config=config)
39 39
40 40
41 41 # Routing/Session/Cache Middleware
42 42 app = RoutesMiddleware(app, config['routes.map'])
43 43 app = SessionMiddleware(app, config)
44 44
45 45 # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
46 46 #set the https based on HTTP_X_URL_SCHEME
47 47
48 48 app = SimpleHg(app, config)
49 49
50 50 if asbool(full_stack):
51 51 # Handle Python exceptions
52 52 app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
53 53
54 54 # Display error documents for 401, 403, 404 status codes (and
55 55 # 500 when debug is disabled)
56 56 if asbool(config['debug']):
57 57 app = StatusCodeRedirect(app)
58 58 else:
59 59 app = StatusCodeRedirect(app, [400, 401, 403, 404, 500])
60 60
61 61 #enable https redirets based on HTTP_X_URL_SCHEME set by proxy
62 62 app = HttpsFixup(app)
63 63
64 64 # Establish the Registry for this application
65 65 app = RegistryManager(app)
66 66
67 67 if asbool(static_files):
68 68 # Serve static files
69 69 static_app = StaticURLParser(config['pylons.paths']['static_files'])
70 70 app = Cascade([static_app, app])
71 71
72 app.config = config
72 app.config = config
73 73
74 74 return app
75 75
General Comments 0
You need to be logged in to leave comments. Login now