summaryrefslogtreecommitdiff
path: root/repoze/bfg/wsgiadapter.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2008-07-14 20:46:19 +0000
committerChris McDonough <chrism@agendaless.com>2008-07-14 20:46:19 +0000
commit4ba8c2852312cc9e7d82c0c4ceb09d370e21ddf8 (patch)
tree1697ebf6a64fca05d63952feb1059bbe42a833c4 /repoze/bfg/wsgiadapter.py
parent4bbd6a3d08c64471e23adaf6e566709e0ceaf480 (diff)
downloadpyramid-4ba8c2852312cc9e7d82c0c4ceb09d370e21ddf8.tar.gz
pyramid-4ba8c2852312cc9e7d82c0c4ceb09d370e21ddf8.tar.bz2
pyramid-4ba8c2852312cc9e7d82c0c4ceb09d370e21ddf8.zip
Really allow views to be functions.
Diffstat (limited to 'repoze/bfg/wsgiadapter.py')
-rw-r--r--repoze/bfg/wsgiadapter.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/repoze/bfg/wsgiadapter.py b/repoze/bfg/wsgiadapter.py
index 16effe1a5..9b35c6aa2 100644
--- a/repoze/bfg/wsgiadapter.py
+++ b/repoze/bfg/wsgiadapter.py
@@ -15,6 +15,13 @@ class IViewSecurityPolicy(Interface):
otherwise it should return a WSGI application representing an
unauthorized view"""
+def isResponse(ob):
+ if ( hasattr(ob, 'app_iter') and hasattr(ob, 'headerlist') and
+ hasattr(ob, 'status') ):
+ if ( hasattr(ob.app_iter, '__iter__') and
+ hasattr(ob.headerlist, '__iter__') ):
+ return True
+
class NaiveWSGIViewAdapter:
classProvides(IWSGIApplicationFactory)
implements(IWSGIApplication)
@@ -44,7 +51,10 @@ class NaiveWSGIViewAdapter:
'start_response':start_response,
}
- response = mapply(view, positional = (), keyword = kwdict)
+ if isResponse(view):
+ response = view
+ else:
+ response = mapply(view, positional = (), keyword = kwdict)
if not catch_response:
catch_response = (response.status, response.headerlist)
start_response(*catch_response)