blob: f76360c27fcb9eaea586709659f06460142a5296 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
from zope.interface import implements
from zope.interface import classProvides
from repoze.bfg.interfaces import IWSGIApplicationFactory
from repoze.bfg.interfaces import IWSGIApplication
from repoze.bfg.mapply import mapply
class NaiveWSGIViewAdapter:
classProvides(IWSGIApplicationFactory)
implements(IWSGIApplication)
def __init__(self, view, request):
self.view = view
self.request = request
def __call__(self, environ, start_response):
catch_response = []
def replace_start_response(status, headers):
catch_response[:] = (status, headers)
kwdict = {
'request':self.request,
'environ':environ,
'start_response':start_response,
}
response = mapply(self.view, positional = (), keyword = kwdict)
if not catch_response:
catch_response = (response.status, response.headerlist)
start_response(*catch_response)
return response.app_iter
|