From 4ba8c2852312cc9e7d82c0c4ceb09d370e21ddf8 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 14 Jul 2008 20:46:19 +0000 Subject: Really allow views to be functions. --- repoze/bfg/wsgiadapter.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'repoze/bfg/wsgiadapter.py') 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) -- cgit v1.2.3