allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kentontay...@apache.org
Subject [allura] 07/12: [#8273] TG 2.3.0: signature of TGController.__call__ changed
Date Tue, 09 Apr 2019 17:02:42 GMT
This is an automated email from the ASF dual-hosted git repository.

kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit ce5d2900a1bd71308272cf21a8f7efec848aac4d
Author: Dave Brondsema <dave@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)


Mime
View raw message