##// END OF EJS Templates
vcs: Do not pass the backend key into the scm app instances....
Martin Bornhold -
r951:8ff080b9 default
parent child Browse files
Show More
@@ -77,7 +77,7 b' class SimpleGit(simplevcs.SimpleVCS):'
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 repo_path, repo_name, config)
81
81
82 def _create_config(self, extras, repo_name):
82 def _create_config(self, extras, repo_name):
83 extras['git_update_server_info'] = utils2.str2bool(
83 extras['git_update_server_info'] = utils2.str2bool(
@@ -72,7 +72,7 b' class SimpleHg(simplevcs.SimpleVCS):'
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 repo_path, repo_name, config)
76
76
77 def _create_config(self, extras, repo_name):
77 def _create_config(self, extras, repo_name):
78 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, backend):
37 def create_git_wsgi_app(repo_path, repo_name, config):
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, backend, repo_path, repo_name, config)
48 factory, repo_path, repo_name, config)
49
49
50
50
51 def create_hg_wsgi_app(repo_path, repo_name, config, backend):
51 def create_hg_wsgi_app(repo_path, repo_name, config):
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, backend, repo_path, repo_name, config)
63 factory, 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, backend):
40 def create_git_wsgi_app(repo_path, repo_name, config):
41 url = _vcs_streaming_url() + 'git/'
41 url = _vcs_streaming_url() + 'git/'
42 return VcsHttpProxy(url, repo_path, repo_name, config, backend)
42 return VcsHttpProxy(url, repo_path, repo_name, config)
43
43
44
44
45 def create_hg_wsgi_app(repo_path, repo_name, config, backend):
45 def create_hg_wsgi_app(repo_path, repo_name, config):
46 url = _vcs_streaming_url() + 'hg/'
46 url = _vcs_streaming_url() + 'hg/'
47 return VcsHttpProxy(url, repo_path, repo_name, config, backend)
47 return VcsHttpProxy(url, repo_path, repo_name, config)
48
48
49
49
50 def _vcs_streaming_url():
50 def _vcs_streaming_url():
@@ -67,7 +67,7 b' class VcsHttpProxy(object):'
67 server as well.
67 server as well.
68 """
68 """
69
69
70 def __init__(self, url, repo_path, repo_name, config, backend):
70 def __init__(self, url, repo_path, repo_name, config):
71 """
71 """
72 :param str url: The URL of the VCSServer to call.
72 :param str url: The URL of the VCSServer to call.
73 """
73 """
@@ -75,7 +75,6 b' class VcsHttpProxy(object):'
75 self._repo_name = repo_name
75 self._repo_name = repo_name
76 self._repo_path = repo_path
76 self._repo_path = repo_path
77 self._config = config
77 self._config = config
78 self._backend = backend
79 log.debug(
78 log.debug(
80 "Creating VcsHttpProxy for repo %s, url %s",
79 "Creating VcsHttpProxy for repo %s, url %s",
81 repo_name, url)
80 repo_name, url)
@@ -56,18 +56,16 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, backend, *args, **kwargs):
59 def __init__(self, remote_wsgi, *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.
66 :param args: args to be passed to the app creation
65 :param args: args to be passed to the app creation
67 :param kwargs: kwargs to be passed to the app creation
66 :param kwargs: kwargs to be passed to the app creation
68 """
67 """
69 self._remote_wsgi = remote_wsgi
68 self._remote_wsgi = remote_wsgi
70 self._backend = backend
71 self._args = args
69 self._args = args
72 self._kwargs = kwargs
70 self._kwargs = kwargs
73
71
@@ -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, backend):
30 def create_git_wsgi_app(repo_path, repo_name, config):
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, backend):
34 def create_hg_wsgi_app(repo_path, repo_name, config):
35 return mock_hg_wsgi
35 return mock_hg_wsgi
36
36
37
37
@@ -24,7 +24,6 b' import pytest'
24 import webtest
24 import webtest
25
25
26 from rhodecode.lib.middleware.utils import scm_app_http, scm_app
26 from rhodecode.lib.middleware.utils import scm_app_http, scm_app
27 from rhodecode.lib.middleware.simplegit import SimpleGit
28 from rhodecode.lib.vcs.conf import settings
27 from rhodecode.lib.vcs.conf import settings
29
28
30
29
@@ -34,7 +33,7 b' def vcs_http_app(vcsserver_http_echo_app'
34 """
33 """
35 git_url = vcsserver_http_echo_app.http_url + 'stream/git/'
34 git_url = vcsserver_http_echo_app.http_url + 'stream/git/'
36 vcs_http_proxy = scm_app_http.VcsHttpProxy(
35 vcs_http_proxy = scm_app_http.VcsHttpProxy(
37 git_url, 'stub_path', 'stub_name', None, 'stub_backend')
36 git_url, 'stub_path', 'stub_name', None)
38 app = webtest.TestApp(vcs_http_proxy)
37 app = webtest.TestApp(vcs_http_proxy)
39 return app
38 return app
40
39
@@ -112,7 +111,7 b' def vcs_pyro4_app(vcsserver_pyro_echo_ap'
112 with mock.patch('rhodecode.lib.middleware.utils.scm_app.GIT_REMOTE_WSGI',
111 with mock.patch('rhodecode.lib.middleware.utils.scm_app.GIT_REMOTE_WSGI',
113 GIT_REMOTE_WSGI):
112 GIT_REMOTE_WSGI):
114 pyro4_app = scm_app.create_git_wsgi_app(
113 pyro4_app = scm_app.create_git_wsgi_app(
115 'stub_path', 'stub_name', stub_config, SimpleGit.SCM)
114 'stub_path', 'stub_name', stub_config)
116 app = webtest.TestApp(pyro4_app)
115 app = webtest.TestApp(pyro4_app)
117 return app
116 return app
118
117
@@ -133,4 +133,4 b' def create_scm_app():'
133 """
133 """
134 echo_app_url = os.environ["RC_ECHO_URL"]
134 echo_app_url = os.environ["RC_ECHO_URL"]
135 return scm_app_http.VcsHttpProxy(
135 return scm_app_http.VcsHttpProxy(
136 echo_app_url, 'stub_path', 'stub_name', None, 'stub_backend')
136 echo_app_url, 'stub_path', 'stub_name', None)
@@ -86,8 +86,7 b' def test_remote_app_caller():'
86 return (['content'], '200 OK', [('Content-Type', 'text/plain')])
86 return (['content'], '200 OK', [('Content-Type', 'text/plain')])
87
87
88 wrapper_app = wsgi_app_caller_client.RemoteAppCaller(
88 wrapper_app = wsgi_app_caller_client.RemoteAppCaller(
89 RemoteAppCallerMock(), 'dummy-backend',
89 RemoteAppCallerMock(), 'a1', 'a2', arg3='a3', arg4='a4')
90 'a1', 'a2', arg3='a3', arg4='a4')
91
90
92 test_app = webtest.TestApp(wrapper_app)
91 test_app = webtest.TestApp(wrapper_app)
93
92
@@ -95,7 +94,6 b' def test_remote_app_caller():'
95
94
96 assert response.status == '200 OK'
95 assert response.status == '200 OK'
97 assert sorted(response.headers.items()) == sorted([
96 assert sorted(response.headers.items()) == sorted([
98 ('X-RhodeCode-Backend', 'dummy-backend'),
99 ('Content-Type', 'text/plain'),
97 ('Content-Type', 'text/plain'),
100 ('Content-Length', '7'),
98 ('Content-Length', '7'),
101 ])
99 ])
General Comments 0
You need to be logged in to leave comments. Login now