Show More
@@ -76,7 +76,8 b' class SimpleGit(simplevcs.SimpleVCS):' | |||||
76 | return 'pull' |
|
76 | return 'pull' | |
77 |
|
77 | |||
78 | def _create_wsgi_app(self, repo_path, repo_name, config): |
|
78 | def _create_wsgi_app(self, repo_path, repo_name, config): | |
79 |
return self.scm_app.create_git_wsgi_app( |
|
79 | return self.scm_app.create_git_wsgi_app( | |
|
80 | repo_path, repo_name, config, self.SCM) | |||
80 |
|
81 | |||
81 | def _create_config(self, extras, repo_name): |
|
82 | def _create_config(self, extras, repo_name): | |
82 | extras['git_update_server_info'] = utils2.str2bool( |
|
83 | extras['git_update_server_info'] = utils2.str2bool( |
@@ -71,7 +71,8 b' class SimpleHg(simplevcs.SimpleVCS):' | |||||
71 | return 'pull' |
|
71 | return 'pull' | |
72 |
|
72 | |||
73 | def _create_wsgi_app(self, repo_path, repo_name, config): |
|
73 | def _create_wsgi_app(self, repo_path, repo_name, config): | |
74 |
return self.scm_app.create_hg_wsgi_app( |
|
74 | return self.scm_app.create_hg_wsgi_app( | |
|
75 | repo_path, repo_name, config, self.SCM) | |||
75 |
|
76 | |||
76 | def _create_config(self, extras, repo_name): |
|
77 | def _create_config(self, extras, repo_name): | |
77 | config = utils.make_db_config(repo=repo_name) |
|
78 | config = utils.make_db_config(repo=repo_name) |
@@ -34,7 +34,7 b' HG_REMOTE_WSGI = None' | |||||
34 | GIT_REMOTE_WSGI = None |
|
34 | GIT_REMOTE_WSGI = None | |
35 |
|
35 | |||
36 |
|
36 | |||
37 | def create_git_wsgi_app(repo_path, repo_name, config): |
|
37 | def create_git_wsgi_app(repo_path, repo_name, config, backend): | |
38 | """ |
|
38 | """ | |
39 | Return a WSGI app backed by a remote app to handle Git. |
|
39 | Return a WSGI app backed by a remote app to handle Git. | |
40 |
|
40 | |||
@@ -45,10 +45,10 b' def create_git_wsgi_app(repo_path, repo_' | |||||
45 | log.error('Pyro server has not been initialized yet') |
|
45 | log.error('Pyro server has not been initialized yet') | |
46 |
|
46 | |||
47 | return wsgi_app_caller_client.RemoteAppCaller( |
|
47 | return wsgi_app_caller_client.RemoteAppCaller( | |
48 | factory, repo_path, repo_name, config) |
|
48 | factory, backend, repo_path, repo_name, config) | |
49 |
|
49 | |||
50 |
|
50 | |||
51 | def create_hg_wsgi_app(repo_path, repo_name, config): |
|
51 | def create_hg_wsgi_app(repo_path, repo_name, config, backend): | |
52 | """ |
|
52 | """ | |
53 | Return a WSGI app backed by a remote app to handle Mercurial. |
|
53 | Return a WSGI app backed by a remote app to handle Mercurial. | |
54 |
|
54 | |||
@@ -60,4 +60,4 b' def create_hg_wsgi_app(repo_path, repo_n' | |||||
60 | log.error('Pyro server has not been initialized yet') |
|
60 | log.error('Pyro server has not been initialized yet') | |
61 |
|
61 | |||
62 | return wsgi_app_caller_client.RemoteAppCaller( |
|
62 | return wsgi_app_caller_client.RemoteAppCaller( | |
63 | factory, repo_path, repo_name, config) |
|
63 | factory, backend, repo_path, repo_name, config) |
@@ -37,14 +37,14 b' import rhodecode' | |||||
37 | log = logging.getLogger(__name__) |
|
37 | log = logging.getLogger(__name__) | |
38 |
|
38 | |||
39 |
|
39 | |||
40 | def create_git_wsgi_app(repo_path, repo_name, config): |
|
40 | def create_git_wsgi_app(repo_path, repo_name, config, backend): | |
41 | url = _vcs_streaming_url() + 'git/' |
|
41 | url = _vcs_streaming_url() + 'git/' | |
42 |
return VcsHttpProxy(url, repo_path, repo_name, config, |
|
42 | return VcsHttpProxy(url, repo_path, repo_name, config, backend) | |
43 |
|
43 | |||
44 |
|
44 | |||
45 | def create_hg_wsgi_app(repo_path, repo_name, config): |
|
45 | def create_hg_wsgi_app(repo_path, repo_name, config, backend): | |
46 | url = _vcs_streaming_url() + 'hg/' |
|
46 | url = _vcs_streaming_url() + 'hg/' | |
47 |
return VcsHttpProxy(url, repo_path, repo_name, config, |
|
47 | return VcsHttpProxy(url, repo_path, repo_name, config, backend) | |
48 |
|
48 | |||
49 |
|
49 | |||
50 | def _vcs_streaming_url(): |
|
50 | def _vcs_streaming_url(): |
@@ -56,16 +56,18 b' class RemoteAppCaller(object):' | |||||
56 | It first cleans the environment, so as to reduce the data transferred. |
|
56 | It first cleans the environment, so as to reduce the data transferred. | |
57 | """ |
|
57 | """ | |
58 |
|
58 | |||
59 | def __init__(self, remote_wsgi, *args, **kwargs): |
|
59 | def __init__(self, remote_wsgi, backend, *args, **kwargs): | |
60 | """ |
|
60 | """ | |
61 | :param remote_wsgi: The remote wsgi object that creates a |
|
61 | :param remote_wsgi: The remote wsgi object that creates a | |
62 | WSGIAppCaller. This object |
|
62 | WSGIAppCaller. This object | |
63 | has to have a handle method, with the signature: |
|
63 | has to have a handle method, with the signature: | |
64 | handle(environ, start_response, *args, **kwargs) |
|
64 | handle(environ, start_response, *args, **kwargs) | |
|
65 | :param backend: Key (str) of the SCM backend that is in use. | |||
65 | :param args: args to be passed to the app creation |
|
66 | :param args: args to be passed to the app creation | |
66 | :param kwargs: kwargs to be passed to the app creation |
|
67 | :param kwargs: kwargs to be passed to the app creation | |
67 | """ |
|
68 | """ | |
68 | self._remote_wsgi = remote_wsgi |
|
69 | self._remote_wsgi = remote_wsgi | |
|
70 | self._backend = backend | |||
69 | self._args = args |
|
71 | self._args = args | |
70 | self._kwargs = kwargs |
|
72 | self._kwargs = kwargs | |
71 |
|
73 | |||
@@ -92,6 +94,10 b' class RemoteAppCaller(object):' | |||||
92 | data, status, headers = self._remote_wsgi.handle( |
|
94 | data, status, headers = self._remote_wsgi.handle( | |
93 | clean_environ, input_data, *self._args, **self._kwargs) |
|
95 | clean_environ, input_data, *self._args, **self._kwargs) | |
94 |
|
96 | |||
|
97 | # Add custom response header to indicate that this is a VCS response | |||
|
98 | # and which backend is used. | |||
|
99 | headers.append(('X-RhodeCode-Backend', self._backend)) | |||
|
100 | ||||
95 | log.debug("Got result from proxy, returning to WSGI container") |
|
101 | log.debug("Got result from proxy, returning to WSGI container") | |
96 | start_response(status, headers) |
|
102 | start_response(status, headers) | |
97 |
|
103 |
@@ -27,11 +27,11 b' for testing purposes.' | |||||
27 | import mock |
|
27 | import mock | |
28 |
|
28 | |||
29 |
|
29 | |||
30 | def create_git_wsgi_app(repo_path, repo_name, config): |
|
30 | def create_git_wsgi_app(repo_path, repo_name, config, backend): | |
31 | return mock_git_wsgi |
|
31 | return mock_git_wsgi | |
32 |
|
32 | |||
33 |
|
33 | |||
34 | def create_hg_wsgi_app(repo_path, repo_name, config): |
|
34 | def create_hg_wsgi_app(repo_path, repo_name, config, backend): | |
35 | return mock_hg_wsgi |
|
35 | return mock_hg_wsgi | |
36 |
|
36 | |||
37 |
|
37 |
General Comments 0
You need to be logged in to leave comments.
Login now