def __call__(self, environ, start_response):
        # initialize a session for the current user
        _tls.current_session = Session(lifetime=self.lifetime, no_datastore=self.no_datastore, cookie_only_threshold=self.cookie_only_thresh, cookie_key=self.cookie_key)

        # create a hook for us to insert a cookie into the response headers
        def my_start_response(status, headers, exc_info=None):
            try:
                _tls.current_session.save() # store the session if it was changed
            except __HOLE__:  # 1Mb memcache limit
                _tls.current_session.clear()

            for ch in _tls.current_session.make_cookie_headers():
                headers.append(('Set-Cookie', ch))

            return start_response(status, headers, exc_info)

        # let the app do its thing
        return self.app(environ, my_start_response)
dataset/ETHPy150Open rwl/muntjac/appengine_config.py/GaeSessionMiddleware.__call__