Mercurial > kallithea
annotate rhodecode/lib/middleware/wrapper.py @ 4006:cdf10b3df899
Allow RhodeCode maintainers to specify a custom bug tracker.
This allows people who maintain large RhodeCode installations to setup their
own bug tracker and respond to requests against their specific installation.
The maintainer is then free to forward problems with RhodeCode to the
canonical issue tracker on bitbucket.
If the config option "bugtracker" is present, its value will be used with the
"Report a bug" button. If left blank, this disables the button. If no value is
present, then the default is used. This is so that the new config option
doesn't break installations of RhodeCode upgrading to a newer version and to
allow easier installation for the common use case.
author | Jonathan Sternberg <jonathansternberg@gmail.com> |
---|---|
date | Mon, 17 Jun 2013 12:41:28 -0400 |
parents | a76ab0130dbe |
children | ffd45b185016 |
rev | line source |
---|---|
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:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 """ |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 rhodecode.lib.middleware.wrapper |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 request time mesuring app |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 :created_on: May 23, 2013 |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 :author: marcink |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 :license: GPLv3, see COPYING for more details. |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 """ |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 # This program is free software: you can redistribute it and/or modify |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 # it under the terms of the GNU General Public License as published by |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 # the Free Software Foundation, either version 3 of the License, or |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 # (at your option) any later version. |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 # |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 # This program is distributed in the hope that it will be useful, |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 # GNU General Public License for more details. |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 # |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 # You should have received a copy of the GNU General Public License |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 import time |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 import logging |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 from rhodecode.lib.base import _get_ip_addr, _get_access_path |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 from rhodecode.lib.utils2 import safe_unicode |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 class RequestWrapper(object): |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 def __init__(self, app, config): |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 self.application = app |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 self.config = config |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 def __call__(self, environ, start_response): |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 start = time.time() |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 try: |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 return self.application(environ, start_response) |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 finally: |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 log = logging.getLogger('rhodecode.' + self.__class__.__name__) |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 log.info('IP: %s Request to %s time: %.3fs' % ( |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 _get_ip_addr(environ), |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 safe_unicode(_get_access_path(environ)), time.time() - start) |
d997a314d18a
moved time measure of request to separate middleware for better results (the last one in stack)
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 ) |