示例#1
0
    def before_request():
        g.debugtext = ""
        g.request_start_time = time.time()
        g.request_time = lambda: "%.5f" % (time.time() - g.request_start_time)

        lang = request.cookies.get('uselang')
        if lang is not None:
            msg.switch_language(lang)
示例#2
0
文件: inject.py 项目: nullzero/wpcgi
    def before_request():
        g.debugtext = ""
        g.request_start_time = time.time()
        g.request_time = lambda: "%.5f" % (time.time() - g.request_start_time)

        lang = request.cookies.get('uselang')
        if lang is not None:
            msg.switch_language(lang)
示例#3
0
 def new_fn(*in_args, **in_kwargs):
     lang = request.args.get('uselang', None)
     setcookie = (lang and msg.switch_language(lang))
     res = fn(*in_args, **in_kwargs)
     response = make_response(res)
     if setcookie:
         response.set_cookie('uselang', lang)
     return response
示例#4
0
 def new_fn(*in_args, **in_kwargs):
     lang = request.args.get("uselang", None)
     setcookie = lang and msg.switch_language(lang)
     res = fn(*in_args, **in_kwargs)
     response = make_response(res)
     if setcookie:
         response.set_cookie("uselang", lang)
     return response