Files @ a83a1799480c
Branch filter:

Location: kallithea/pylons_app/lib/middleware/https_fixup.py

Marcin Kuzminski
Reimplemented way of caching repos list, hg model now get's repos objects right from cached dict, this way we skipp creating instances of MercurialRepository and gain performance. Some import cleanup
class HttpsFixup(object):
    def __init__(self, app):
        self.application = app
    
    def __call__(self, environ, start_response):
        self.__fixup(environ)
        return self.application(environ, start_response)
    
    
    def __fixup(self, environ):
        """Function to fixup the environ as needed. In order to use this
        middleware you should set this header inside your 
        proxy ie. nginx, apache etc.
        """
        proto = environ.get('HTTP_X_URL_SCHEME')
            
        if proto == 'https':
            environ['wsgi.url_scheme'] = proto
        else:
            environ['wsgi.url_scheme'] = 'http'
        return None