Mercurial > kallithea
annotate rhodecode/config/middleware.py @ 4116:ffd45b185016 rhodecode-2.2.5-gpl
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
This imports changes between changesets 21af6c4eab3d and 6177597791c2 in
RhodeCode's original repository, including only changes to Python files and HTML.
RhodeCode clearly licensed its changes to these files under GPLv3
in their /LICENSE file, which states the following:
The Python code and integrated HTML are licensed under the GPLv3 license.
(See:
https://code.rhodecode.com/rhodecode/files/v2.2.5/LICENSE
or
http://web.archive.org/web/20140512193334/https://code.rhodecode.com/rhodecode/files/f3b123159901f15426d18e3dc395e8369f70ebe0/LICENSE
for an online copy of that LICENSE file)
Conservancy reviewed these changes and confirmed that they can be licensed as
a whole to the Kallithea project under GPLv3-only.
While some of the contents committed herein are clearly licensed
GPLv3-or-later, on the whole we must assume the are GPLv3-only, since the
statement above from RhodeCode indicates that they intend GPLv3-only as their
license, per GPLv3ยง14 and other relevant sections of GPLv3.
author | Bradley M. Kuhn <bkuhn@sfconservancy.org> |
---|---|
date | Wed, 02 Jul 2014 19:03:13 -0400 |
parents | 3563bb7b4b82 |
children | 7e5f8c12a3fc |
rev | line source |
---|---|
4116
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3700
diff
changeset
|
1 # -*- coding: utf-8 -*- |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3700
diff
changeset
|
2 # This program is free software: you can redistribute it and/or modify |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3700
diff
changeset
|
3 # it under the terms of the GNU General Public License as published by |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3700
diff
changeset
|
4 # the Free Software Foundation, either version 3 of the License, or |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3700
diff
changeset
|
5 # (at your option) any later version. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3700
diff
changeset
|
6 # |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3700
diff
changeset
|
7 # This program is distributed in the hope that it will be useful, |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3700
diff
changeset
|
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3700
diff
changeset
|
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3700
diff
changeset
|
10 # GNU General Public License for more details. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3700
diff
changeset
|
11 # |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3700
diff
changeset
|
12 # You should have received a copy of the GNU General Public License |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3700
diff
changeset
|
13 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3700
diff
changeset
|
14 """ |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3700
diff
changeset
|
15 Pylons middleware initialization |
ffd45b185016
Imported some of the GPLv3'd changes from RhodeCode v2.2.5.
Bradley M. Kuhn <bkuhn@sfconservancy.org>
parents:
3700
diff
changeset
|
16 """ |
1018
da5075ce681c
rhodecode config module refactoring
Marcin Kuzminski <marcin@python-works.com>
parents:
914
diff
changeset
|
17 |
43 | 18 from beaker.middleware import SessionMiddleware |
1018
da5075ce681c
rhodecode config module refactoring
Marcin Kuzminski <marcin@python-works.com>
parents:
914
diff
changeset
|
19 from routes.middleware import RoutesMiddleware |
0 | 20 from paste.cascade import Cascade |
21 from paste.registry import RegistryManager | |
22 from paste.urlparser import StaticURLParser | |
23 from paste.deploy.converters import asbool | |
1018
da5075ce681c
rhodecode config module refactoring
Marcin Kuzminski <marcin@python-works.com>
parents:
914
diff
changeset
|
24 from paste.gzipper import make_gzip_middleware |
da5075ce681c
rhodecode config module refactoring
Marcin Kuzminski <marcin@python-works.com>
parents:
914
diff
changeset
|
25 |
0 | 26 from pylons.middleware import ErrorHandler, StatusCodeRedirect |
27 from pylons.wsgiapp import PylonsApp | |
1018
da5075ce681c
rhodecode config module refactoring
Marcin Kuzminski <marcin@python-works.com>
parents:
914
diff
changeset
|
28 |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
29 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
|
30 from rhodecode.lib.middleware.simplegit import SimpleGit |
547
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
31 from rhodecode.lib.middleware.https_fixup import HttpsFixup |
1e757ac98988
renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents:
341
diff
changeset
|
32 from rhodecode.config.environment import load_environment |
3489
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
2939
diff
changeset
|
33 from rhodecode.lib.middleware.wrapper import RequestWrapper |
12 | 34 |
1205
f4807acf643d
added __license__ into main of rhodecode, PEP8ify
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
35 |
43 | 36 def make_app(global_conf, full_stack=True, static_files=True, **app_conf): |
0 | 37 """Create a Pylons WSGI application and return it |
38 | |
39 ``global_conf`` | |
40 The inherited configuration for this application. Normally from | |
41 the [DEFAULT] section of the Paste ini file. | |
42 | |
43 ``full_stack`` | |
12 | 44 Whether or not this application provides a full WSGI stack (by |
45 default, meaning it handles its own exceptions and errors). | |
46 Disable full_stack when this application is "managed" by | |
47 another WSGI middleware. | |
0 | 48 |
49 ``app_conf`` | |
50 The application's local configuration. Normally specified in | |
51 the [app:<name>] section of the Paste ini file (where <name> | |
52 defaults to main). | |
53 | |
54 """ | |
55 # Configure the Pylons environment | |
43 | 56 config = load_environment(global_conf, app_conf) |
57 | |
0 | 58 # The Pylons WSGI app |
43 | 59 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
|
60 |
0 | 61 # Routing/Session/Cache Middleware |
62 app = RoutesMiddleware(app, config['routes.map']) | |
21 | 63 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
|
64 |
204
a8ea3ce3cdc4
Created middleware package. Crated special middleware to handle https requests redirections.
Marcin Kuzminski <marcin@python-works.com>
parents:
203
diff
changeset
|
65 # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) |
1355
bfc529377cdc
added simple profiling middleware controlled by .ini file flag
Marcin Kuzminski <marcin@python-works.com>
parents:
1205
diff
changeset
|
66 if asbool(config['pdebug']): |
bfc529377cdc
added simple profiling middleware controlled by .ini file flag
Marcin Kuzminski <marcin@python-works.com>
parents:
1205
diff
changeset
|
67 from rhodecode.lib.profiler import ProfilingMiddleware |
bfc529377cdc
added simple profiling middleware controlled by .ini file flag
Marcin Kuzminski <marcin@python-works.com>
parents:
1205
diff
changeset
|
68 app = ProfilingMiddleware(app) |
635
fd63782c4426
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Marcin Kuzminski <marcin@python-works.com>
parents:
547
diff
changeset
|
69 |
1982
87f0800abc7b
#227 Initial version of repository groups permissions system
Marcin Kuzminski <marcin@python-works.com>
parents:
1696
diff
changeset
|
70 if asbool(full_stack): |
1534
72c3cea0175a
fixes problem with basic auth and pushes
Marcin Kuzminski <marcin@python-works.com>
parents:
1496
diff
changeset
|
71 |
2939
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
72 from rhodecode.lib.middleware.sentry import Sentry |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
73 from rhodecode.lib.middleware.errormator import Errormator |
3511
e1568c0bac1f
only use errormator if it's actually turned on in .ini file
Marcin Kuzminski <marcin@python-works.com>
parents:
3489
diff
changeset
|
74 if Errormator and asbool(config['app_conf'].get('errormator')): |
2939
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
75 app = Errormator(app, config) |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
76 elif Sentry: |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
77 app = Sentry(app, config) |
dbe3cfb81446
Added Errormator and Sentry support part of pull request #71
Marcin Kuzminski <marcin@python-works.com>
parents:
1982
diff
changeset
|
78 |
0 | 79 # Handle Python exceptions |
80 app = ErrorHandler(app, global_conf, **config['pylons.errorware']) | |
81 | |
1696
2d85e969d78a
overcomes git push issues with errormiddleware and debug off
Marcin Kuzminski <marcin@python-works.com>
parents:
1534
diff
changeset
|
82 # we want our low level middleware to get to the request ASAP. We don't |
2d85e969d78a
overcomes git push issues with errormiddleware and debug off
Marcin Kuzminski <marcin@python-works.com>
parents:
1534
diff
changeset
|
83 # need any pylons stack middleware in them |
2d85e969d78a
overcomes git push issues with errormiddleware and debug off
Marcin Kuzminski <marcin@python-works.com>
parents:
1534
diff
changeset
|
84 app = SimpleHg(app, config) |
2d85e969d78a
overcomes git push issues with errormiddleware and debug off
Marcin Kuzminski <marcin@python-works.com>
parents:
1534
diff
changeset
|
85 app = SimpleGit(app, config) |
3489
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
2939
diff
changeset
|
86 app = RequestWrapper(app, config) |
0 | 87 # Display error documents for 401, 403, 404 status codes (and |
88 # 500 when debug is disabled) | |
89 if asbool(config['debug']): | |
86
e47d1db5ef20
Added few options to configs,
Marcin Kuzminski <marcin@python-blog.com>
parents:
49
diff
changeset
|
90 app = StatusCodeRedirect(app) |
0 | 91 else: |
86
e47d1db5ef20
Added few options to configs,
Marcin Kuzminski <marcin@python-blog.com>
parents:
49
diff
changeset
|
92 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
|
93 |
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
|
94 #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
|
95 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
|
96 |
0 | 97 # Establish the Registry for this application |
98 app = RegistryManager(app) | |
99 | |
43 | 100 if asbool(static_files): |
101 # Serve static files | |
102 static_app = StaticURLParser(config['pylons.paths']['static_files']) | |
103 app = Cascade([static_app, app]) | |
702
a9158dfa05cc
added gzip middleware
Marcin Kuzminski <marcin@python-works.com>
parents:
635
diff
changeset
|
104 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
|
105 |
269
183c06406127
fixed bug in middleware config
Marcin Kuzminski <marcin@python-works.com>
parents:
216
diff
changeset
|
106 app.config = config |
43 | 107 |
12 | 108 return app |