human
Complete the below
def make_flask_stack(conf, **app_conf):

    ''''This has to pass the flask app through all the same middleware that
    Pylons used'
    '''

Give me a the Python code you requested?
assistant
#Here is the Python code you requested.
    root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
    debug = asbool(app_conf.get('debug', app_conf.get('DEBUG', False)))
    testing = asbool(app_conf.get('testing', app_conf.get('TESTING', False)))
    app = flask_app = CKANFlask(__name__)
    app.debug = debug
    app.testing = testing
    app.template_folder = os.path.join(root, 'templates')
    app.app_ctx_globals_class = CKAN_AppCtxGlobals
    app.url_rule_class = CKAN_Rule
    if config:
        app.config.update(config)
    else:
        app.config.update(conf)
        app.config.update(app_conf)
    if (not app.config.get('SECRET_KEY')):
        app.config['SECRET_KEY'] = config.get('beaker.session.secret')
    if (not app.config.get('SECRET_KEY')):
        raise RuntimeError(u'You    must    provide    a    value    for    the    secret    key    with    the    SECRET_KEY    config    option')
    if debug:
        from flask_debugtoolbar import DebugToolbarExtension
        app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = False
        DebugToolbarExtension(app)
    class BeakerSessionInterface(SessionInterface, ):
        def open_session(self, app, request):
            if ('beaker.session' in request.environ):
                return request.environ['beaker.session']
        def save_session(self, app, session, response):
            session.save()
    namespace = 'beaker.session.'
    session_opts = dict([(k.replace('beaker.', ''), v) for (k, v) in config.iteritems() if k.startswith(namespace)])
    if ((not session_opts.get('session.data_dir')) and (session_opts.get('session.type', 'file') == 'file')):
        cache_dir = (app_conf.get('cache_dir') or app_conf.get('cache.dir'))
        session_opts['session.data_dir'] = '{data_dir}/sessions'.format(data_dir=cache_dir)
    app.wsgi_app = SessionMiddleware(app.wsgi_app, session_opts)
    app.session_interface = BeakerSessionInterface()
    extensions = ['jinja2.ext.do', 'jinja2.ext.with_', jinja_extensions.SnippetExtension, jinja_extensions.CkanExtend,...