You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2019/03/27 21:03:18 UTC

[allura] 07/08: [#8273] TG 2.3.0: signature of TGController.__call__ changed

This is an automated email from the ASF dual-hosted git repository.

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

commit e223aa580e78de982d3b74184d0cd2d01f598ac7
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Fri Mar 22 17:55:38 2019 -0400

    [#8273] TG 2.3.0: signature of TGController.__call__ changed
---
 Allura/allura/controllers/basetest_project_root.py |  4 ++--
 Allura/allura/controllers/task.py                  | 12 ++++++++----
 Allura/allura/lib/base.py                          |  4 ++--
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/Allura/allura/controllers/basetest_project_root.py b/Allura/allura/controllers/basetest_project_root.py
index 4d5cad3..5b1adad 100644
--- a/Allura/allura/controllers/basetest_project_root.py
+++ b/Allura/allura/controllers/basetest_project_root.py
@@ -120,7 +120,7 @@ class BasetestProjectRootController(WsgiDispatchController, ProjectController):
         c.app = app
         return app.root, remainder
 
-    def __call__(self, environ, start_response):
+    def __call__(self, environ, context):
         """ Called from a WebTest 'app' instance.
 
 
@@ -142,7 +142,7 @@ class BasetestProjectRootController(WsgiDispatchController, ProjectController):
             environ['beaker.session'].save()
             environ['beaker.session'].persist()
             c.user = auth.authenticate_request()
-        return WsgiDispatchController.__call__(self, environ, start_response)
+        return WsgiDispatchController.__call__(self, environ, context)
 
 
 class DispatchTest(object):
diff --git a/Allura/allura/controllers/task.py b/Allura/allura/controllers/task.py
index cb666ee..e8669d7 100644
--- a/Allura/allura/controllers/task.py
+++ b/Allura/allura/controllers/task.py
@@ -22,12 +22,16 @@ class TaskController(object):
 
     The purpose of this app is to allow us to replicate the
     normal web request environment as closely as possible
-    when executing celery tasks.
+    when executing taskd tasks.
     '''
 
-    def __call__(self, environ, start_response):
+    def __call__(self, environ, context):
+        # see TGController / CoreDispatcher for reference on how this works on a normal controllers
+
         task = environ['task']
         nocapture = environ['nocapture']
         result = task(restore_context=False, nocapture=nocapture)
-        start_response('200 OK', [])
-        return [result]
+        py_response = context.response
+        py_response.headers['Content-Type'] = 'text/plain'  # `None` default is problematic for some middleware
+        py_response.body = result or ''
+        return py_response
diff --git a/Allura/allura/lib/base.py b/Allura/allura/lib/base.py
index 148c3e8..36b1aa4 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, start_response):
+    def __call__(self, environ, context):
         self._setup_request()
-        return super(WsgiDispatchController, self).__call__(environ, start_response)
+        return super(WsgiDispatchController, self).__call__(environ, context)