Switch to unified view

a/Allura/allura/lib/base.py b/Allura/allura/lib/base.py
...
...
16
from allura.lib.custom_middleware import ForgeMiddleware
16
from allura.lib.custom_middleware import ForgeMiddleware
17
17
18
__all__ = ['WsgiDispatchController']
18
__all__ = ['WsgiDispatchController']
19
19
20
def wsgi_dispatch(environ):
20
def wsgi_dispatch(environ):
21
        import allura.model as model
21
    import allura.model as model
22
        host = environ['HTTP_HOST'].lower()
22
    host = environ['HTTP_HOST'].lower()
23
        if host == config['oembed.host']:
23
    if host == config['oembed.host']:
24
            from allura.controllers.oembed import OEmbedController
24
        from allura.controllers.oembed import OEmbedController
25
            return OEmbedController()
25
        return OEmbedController()
26
26
27
        neighborhood = model.Neighborhood.query.get(url_prefix='//' + host + '/')
27
    neighborhood = model.Neighborhood.query.get(url_prefix='//' + host + '/')
28
        if neighborhood:
28
    if neighborhood:
29
            from allura.controllers.project import HostNeighborhoodController
29
        from allura.controllers.project import HostNeighborhoodController
30
            return HostNeighborhoodController(neighborhood.name, neighborhood.shortname_prefix)
30
        return HostNeighborhoodController(neighborhood.name, neighborhood.shortname_prefix)
31
31
32
        if environ['PATH_INFO'].startswith('/_wsgi_/'):
32
    if environ['PATH_INFO'].startswith('/_wsgi_/'):
33
            for ep in pkg_resources.iter_entry_points('allura'):
33
        for ep in pkg_resources.iter_entry_points('allura'):
34
                App = ep.load()
34
            App = ep.load()
35
                if App.wsgi and App.wsgi.handles(environ): return App.wsgi
35
            if App.wsgi and App.wsgi.handles(environ): return App.wsgi
36
37
        return None
36
        return None
38
37
39
class WsgiDispatchController(TGController):
38
class WsgiDispatchController(TGController):
40
    """
39
    """
41
    Base class for the controllers in the application.
40
    Base class for the controllers in the application.
...
...
49
        self._app = self._base_app
48
        self._app = self._base_app
50
        self._app = MingMiddleware(self._app)
49
        self._app = MingMiddleware(self._app)
51
        self._app = ForgeMiddleware(self._app)
50
        self._app = ForgeMiddleware(self._app)
52
51
53
    def _base_app(self, environ, start_response):
52
    def _base_app(self, environ, start_response):
53
        try:
54
        self._setup_request()
54
            self._setup_request()
55
        except exc.HTTPException, err:
56
            return err(environ, start_response)
55
        app = self._wsgi_handler(environ)
57
        app = self._wsgi_handler(environ)
56
        if app is None:
58
        if app is None:
57
            app = lambda e,s: TGController.__call__(self, e, s)
59
            app = lambda e,s: TGController.__call__(self, e, s)
58
        return app(environ, start_response)
60
        return app(environ, start_response)
59
61