Mercurial > kallithea
annotate rhodecode/config/middleware.py @ 997:b79e720bac0c beta
fixed admin log tooltips
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 04 Feb 2011 17:47:02 +0100 |
parents | 110a00c181de |
children | da5075ce681c |
rev | line source |
---|---|
0 | 1 """Pylons middleware initialization""" |
43 | 2 from beaker.middleware import SessionMiddleware |
0 | 3 from paste.cascade import Cascade |
4 from paste.registry import RegistryManager | |
5 from paste.urlparser import StaticURLParser | |
6 from paste.deploy.converters import asbool | |
7 from pylons.middleware import ErrorHandler, StatusCodeRedirect | |
8 from pylons.wsgiapp import PylonsApp | |
9 from routes.middleware import RoutesMiddleware | |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
10 from rhodecode.lib.middleware.simplehg import SimpleHg |
635
fd63782c4426
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
11 from rhodecode.lib.middleware.simplegit import SimpleGit |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
12 from rhodecode.lib.middleware.https_fixup import HttpsFixup |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
13 from rhodecode.config.environment import load_environment |
702
a9158dfa05cc
added gzip middleware
Marcin Kuzminski <marcin@python-works.com>
parents:
635
diff
changeset
|
14 from paste.gzipper import make_gzip_middleware |
12 | 15 |
43 | 16 def make_app(global_conf, full_stack=True, static_files=True, **app_conf): |
0 | 17 """Create a Pylons WSGI application and return it |
18 | |
19 ``global_conf`` | |
20 The inherited configuration for this application. Normally from | |
21 the [DEFAULT] section of the Paste ini file. | |
22 | |
23 ``full_stack`` | |
12 | 24 Whether or not this application provides a full WSGI stack (by |
25 default, meaning it handles its own exceptions and errors). | |
26 Disable full_stack when this application is "managed" by | |
27 another WSGI middleware. | |
0 | 28 |
29 ``app_conf`` | |
30 The application's local configuration. Normally specified in | |
31 the [app:<name>] section of the Paste ini file (where <name> | |
32 defaults to main). | |
33 | |
34 """ | |
35 # Configure the Pylons environment | |
43 | 36 config = load_environment(global_conf, app_conf) |
37 | |
0 | 38 # The Pylons WSGI app |
43 | 39 app = PylonsApp(config=config) |
635
fd63782c4426
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
40 |
0 | 41 # Routing/Session/Cache Middleware |
42 app = RoutesMiddleware(app, config['routes.map']) | |
21 | 43 app = SessionMiddleware(app, config) |
635
fd63782c4426
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
44 |
204
a8ea3ce3cdc4
Created middleware package. Crated special middleware to handle https requests redirections.
Marcin Kuzminski <marcin@python-works.com>
parents:
203
diff
changeset
|
45 # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) |
635
fd63782c4426
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
46 |
101
8b06c420491d
statics moved to pylons.
Marcin Kuzminski <marcin@python-works.com>
parents:
86
diff
changeset
|
47 app = SimpleHg(app, config) |
635
fd63782c4426
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
48 app = SimpleGit(app, config) |
fd63782c4426
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
49 |
0 | 50 if asbool(full_stack): |
51 # Handle Python exceptions | |
52 app = ErrorHandler(app, global_conf, **config['pylons.errorware']) | |
53 | |
54 # Display error documents for 401, 403, 404 status codes (and | |
55 # 500 when debug is disabled) | |
56 if asbool(config['debug']): | |
86
e47d1db5ef20
Added few options to configs,
Marcin Kuzminski <marcin@python-blog.com>
parents:
49
diff
changeset
|
57 app = StatusCodeRedirect(app) |
0 | 58 else: |
86
e47d1db5ef20
Added few options to configs,
Marcin Kuzminski <marcin@python-blog.com>
parents:
49
diff
changeset
|
59 app = StatusCodeRedirect(app, [400, 401, 403, 404, 500]) |
635
fd63782c4426
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
60 |
216
c8162373f214
Cleaned the way based was used to generate submenu for admin, now it's much more clear to use submenu. Cleaned admin and added comment to middleware
Marcin Kuzminski <marcin@python-works.com>
parents:
207
diff
changeset
|
61 #enable https redirets based on HTTP_X_URL_SCHEME set by proxy |
914
110a00c181de
Added force https option into config files
Marcin Kuzminski <marcin@python-works.com>
parents:
702
diff
changeset
|
62 app = HttpsFixup(app, config) |
635
fd63782c4426
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
63 |
0 | 64 # Establish the Registry for this application |
65 app = RegistryManager(app) | |
66 | |
43 | 67 if asbool(static_files): |
68 # Serve static files | |
69 static_app = StaticURLParser(config['pylons.paths']['static_files']) | |
70 app = Cascade([static_app, app]) | |
702
a9158dfa05cc
added gzip middleware
Marcin Kuzminski <marcin@python-works.com>
parents:
635
diff
changeset
|
71 app = make_gzip_middleware(app, global_conf, compress_level=1) |
635
fd63782c4426
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
72 |
269
183c06406127
fixed bug in middleware config
Marcin Kuzminski <marcin@python-works.com>
parents:
216
diff
changeset
|
73 app.config = config |
43 | 74 |
12 | 75 return app |
0 | 76 |