allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [allura] 02/03: [#8276] Change __call__ to _perform_call so any HTTPErrors raised from _setup_request are handled by TG CoreDispater.__call__
Date Thu, 11 Apr 2019 18:54:07 GMT
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8276
in repository https://gitbox.apache.org/repos/asf/allura.git

commit c88e9b78b00a1ddfd02611f468b7f567414e5e1b
Author: Dave Brondsema <dave@brondsema.net>
AuthorDate: Thu Apr 11 11:18:41 2019 -0400

    [#8276] Change __call__ to _perform_call so any HTTPErrors raised from _setup_request
are handled by TG CoreDispater.__call__
---
 Allura/allura/controllers/basetest_project_root.py | 10 ++++------
 Allura/allura/lib/base.py                          |  4 ++--
 Allura/allura/tests/functional/test_auth.py        |  6 ++----
 3 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/Allura/allura/controllers/basetest_project_root.py b/Allura/allura/controllers/basetest_project_root.py
index 5b1adad..dfb51fd 100644
--- a/Allura/allura/controllers/basetest_project_root.py
+++ b/Allura/allura/controllers/basetest_project_root.py
@@ -120,13 +120,11 @@ class BasetestProjectRootController(WsgiDispatchController, ProjectController):
         c.app = app
         return app.root, remainder
 
-    def __call__(self, environ, context):
-        """ Called from a WebTest 'app' instance.
-
-
-        :param environ: Extra environment variables.
+    def _perform_call(self, context):
+        """ Called from a WebTest 'app' instance, going through TurboGears dispatcher code
         Example: self.app.get('/auth/', extra_environ={'disable_auth_magic': "True"})
         """
+        environ = context.request.environ
         c.app = None
         c.project = M.Project.query.get(
             shortname='test', neighborhood_id=self.p_nbhd._id)
@@ -142,7 +140,7 @@ class BasetestProjectRootController(WsgiDispatchController, ProjectController):
             environ['beaker.session'].save()
             environ['beaker.session'].persist()
             c.user = auth.authenticate_request()
-        return WsgiDispatchController.__call__(self, environ, context)
+        return super(BasetestProjectRootController, self)._perform_call(context)
 
 
 class DispatchTest(object):
diff --git a/Allura/allura/lib/base.py b/Allura/allura/lib/base.py
index 36b1aa4..374f85a 100644
--- a/Allura/allura/lib/base.py
+++ b/Allura/allura/lib/base.py
@@ -37,6 +37,6 @@ class WsgiDispatchController(TGController):
         '''Responsible for setting all the values we need to be set on pylons.tmpl_context'''
         raise NotImplementedError, '_setup_request'
 
-    def __call__(self, environ, context):
+    def _perform_call(self, context):
         self._setup_request()
-        return super(WsgiDispatchController, self).__call__(environ, context)
+        return super(WsgiDispatchController, self)._perform_call(context)
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index f28f032..6a11e0f 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -1977,10 +1977,8 @@ class TestPasswordExpire(TestController):
         return f.submit(extra_environ={'username': '*anonymous'})
 
     def assert_redirects(self, where='/'):
-        try:
-            self.app.get(where, extra_environ={'username': 'test-user'}, status=302)
-        except exc.HTTPFound as e:
-            assert_equal(e.location, '/auth/pwd_expired?' + urlencode({'return_to': where}))
+        resp = self.app.get(where, extra_environ={'username': 'test-user'}, status=302)
+        assert_equal(resp.location, 'http://localhost/auth/pwd_expired?' + urlencode({'return_to':
where}))
 
     def assert_not_redirects(self, where='/neighborhood'):
         self.app.get(where, extra_environ={'username': 'test-user'}, status=200)


Mime
View raw message