Switch to unified view

a/Allura/allura/lib/base.py b/Allura/allura/lib/base.py
...
...
16
16
17
    def _setup_request(self):
17
    def _setup_request(self):
18
        '''Responsible for setting all the values we need to be set on pylons.c'''
18
        '''Responsible for setting all the values we need to be set on pylons.c'''
19
        raise NotImplementedError, '_setup_request'
19
        raise NotImplementedError, '_setup_request'
20
20
21
    def _cleanup_request(self):
22
        raise NotImplementedError, '_cleanup_request'
23
21
    def __call__(self, environ, start_response):
24
    def __call__(self, environ, start_response):
22
        host = environ['HTTP_HOST'].lower()
25
        host = environ['HTTP_HOST'].lower()
23
        if host == config['oembed.host']:
26
        if host == config['oembed.host']:
24
            from allura.controllers.oembed import OEmbedController
27
            from allura.controllers.oembed import OEmbedController
25
            return OEmbedController()(environ, start_response)
28
            return OEmbedController()(environ, start_response)
26
        try:
29
        try:
27
            self._setup_request()
30
            self._setup_request()
31
            response = super(WsgiDispatchController, self).__call__(environ, start_response)
32
            return self.cleanup_iterator(response)
28
        except exc.HTTPException, err:
33
        except exc.HTTPException, err:
29
            return err(environ, start_response)
34
            return err(environ, start_response)
30
        return super(WsgiDispatchController, self).__call__(environ, start_response)
35
36
    def cleanup_iterator(self, response):
37
        for chunk in response: yield chunk
38
        self._cleanup_request()
31
39
32
40