当前位置: 首页>>代码示例>>Python>>正文


Python FilesystemSessionStore.save_if_modified方法代码示例

本文整理汇总了Python中werkzeug.contrib.sessions.FilesystemSessionStore.save_if_modified方法的典型用法代码示例。如果您正苦于以下问题:Python FilesystemSessionStore.save_if_modified方法的具体用法?Python FilesystemSessionStore.save_if_modified怎么用?Python FilesystemSessionStore.save_if_modified使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在werkzeug.contrib.sessions.FilesystemSessionStore的用法示例。


在下文中一共展示了FilesystemSessionStore.save_if_modified方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: application

# 需要导入模块: from werkzeug.contrib.sessions import FilesystemSessionStore [as 别名]
# 或者: from werkzeug.contrib.sessions.FilesystemSessionStore import save_if_modified [as 别名]
def application(environ, start_response):
    global CONFIGFILE
    global gConfig,  gRequest, gSessionStore
    if gSessionStore is None:
        gSessionStore = FilesystemSessionStore()
    conf = {}
    # print('CONFIGFILE=%s' % CONFIGFILE)
    conf['config_path'] = CONFIGFILE
    conf['gConfig'] = gConfig
    conf['gRequest'] = gRequest
    conf['gSessionStore'] = gSessionStore
    conf['gClientMongo'] = gClientMongo

    # headers = {}
    mimetype = 'text/plain'
    headerslist = []
    body = ''
    sess = None
    cookie = {}
    statuscode = 200
    if not ip_check(conf, environ):
        mimetype = 'text/json'
        body = json.dumps({'result':'your_ip_access_deny'}, ensure_ascii=True, indent=4)
        response = Response(body, status=statuscode, mimetype=mimetype)
        return response(environ, start_response)
    path_info = environ['PATH_INFO']
    # headers['Content-Type'] = 'text/plain;charset=' + ENCODING

    app = gConfig['wsgi']['application']
    if not app in gConfig['applications']:
        statuscode = 404
        body = 'Not Found'
    if path_info[-1:] == '/':
        if 'indexpage' in gConfig['applications'][app]['static']['page'] \
           and len(gConfig['applications'][app]['static']['page']['indexpage']) > 0:
            path_info = gConfig['applications'][app]['static']['page']['indexpage']
        else:
            statuscode = 404
            body = 'Not Found'
    if len(path_info) > 7 and path_info[:6] == '/proxy':
        pkey = path_info[7:]
        if '/' in pkey :
            idx = pkey.index('/')
            pkey = pkey[:idx]
        if 'proxy' in gConfig['applications'][app] and  len(list(gConfig['applications'][app]['proxy'].keys()))>0:
            if pkey in gConfig['applications'][app]['proxy']:
                pro = gConfig['applications'][app]['proxy'][pkey]
                proxy_placeholder = 'proxy_%s' % pkey
                real_url = pro['url']
                connection_timeout = float(pro['connection_timeout'])
                network_timeout = float(pro['network_timeout'])
                request_headers={}
                # if 'header' in pro:
                #     for k in pro['header'].keys():
                #         if isinstance(pro['header'][k], str):
                #             request_headers[str(k)] = str(pro['header'][k])
                #         elif isinstance(pro['header'][k], list):
                #             s = ','.join( pro['header'][k])
                #             request_headers[str(k)] = str(s)
                statuscode, mimetype, body = handle_http_proxy(conf, environ,
                                                               proxy_placeholder=proxy_placeholder,
                                                               real_url=real_url,
                                                               # ca_cert=ca_cert,
                                                               connection_timeout=connection_timeout,
                                                               network_timeout=network_timeout,
                                                               request_headers=request_headers)
    elif gConfig['applications'][app]['session']['enable_session'].lower() == 'true':

        is_expire = False
        with session_manager(environ):
            sess, cookie, is_expire = session_handle(environ, gRequest, gSessionStore)
            if not 'ip' in sess:
                sess['ip'] = environ['REMOTE_ADDR']
            gSessionStore.save_if_modified(sess)
            urls_need_not_session_check = gConfig['applications'][app]['session']['urls_need_not_session_check']
            if len(urls_need_not_session_check) > 0 \
                and isinstance(urls_need_not_session_check, str)  \
                and path_info == urls_need_not_session_check:
                statuscode, mimetype, body =  getattr(globals()[app], 'handle_url' )(conf, environ, sess)
            elif len(urls_need_not_session_check) > 0 \
                and isinstance(urls_need_not_session_check, list) :
                if path_info in urls_need_not_session_check:
                    if check_is_static(conf, path_info):
                        statuscode, mimetype, body =  handle_static(conf, environ, path_info)
                    else:
                        statuscode, mimetype, body =  getattr(globals()[app], 'handle_url' )(conf, environ, sess)
                else:
                    if not is_expire and len(sess.sid) > 0:
                        if sess and 'username' in sess:
                            if check_is_static(conf, path_info):
                                statuscode, mimetype, body = handle_static(conf, environ, path_info)
                            else:
                                statuscode, mimetype, body = getattr(globals()[app], 'handle_url')(conf, environ, sess)
                        else:
                            if check_is_static(conf, path_info) and not check_is_static_html(conf, path_info):
                                statuscode, mimetype, body = handle_static(conf, environ, path_info)
                            else:
                                statuscode, mimetype, body = handle_static(conf, environ,
                                                                           gConfig['applications'][app]['static'][
                                                                               'page']['unauthorizedpage'])
#.........这里部分代码省略.........
开发者ID:kamijawa,项目名称:pi_server,代码行数:103,代码来源:wsgi_server.py


注:本文中的werkzeug.contrib.sessions.FilesystemSessionStore.save_if_modified方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。