示例#1
0
    def decorated_view(*args, **kwargs):
        slog = (
            request.method,
            current_user.id,
            current_user.nickname,
            time.strftime("%Y-%m-%d %X", time.localtime()),
            request,
            request.form,
        )
        logging.error(slog)
        print slog
        clog = cache.get("johnlog")
        if not clog:
            print "99999999999999"
            cache.set("johnlog", slog)

        slog = cache.get("johnlog")
        print slog

        if not current_user.is_authenticated():
            return current_app.login_manager.unauthorized()
        if current_user.action(fn.__name__):
            return fn(*args, **kwargs)
        if request.is_xhr:
            return jsonify(result=False, error=u"权限不1足")
        abort(403)
示例#2
0
文件: manage.py 项目: coco369/qxh_ecp
def cache_test():
    k = 'TEST'
    v = cache.get(k)
    if v:
        print 'exists = ',v
    else:
        cache.set(k,'1000')
        print 'no exists'
示例#3
0
def cache_test():
    k = 'TEST'
    v = cache.get(k)
    if v:
        print 'exists = ', v
    else:
        cache.set(k, '1000')
        print 'no exists'
示例#4
0
 def do_cache(*args, **kws):
     if isinstance(cache_key,str):key=cache_key
     elif callable(cache_key):key = cache_key(*args,**kws)
     if thread_cache is True:
         if THREAD_CACHES.has_key(cache_key):
             return THREAD_CACHES[cache_key]
     data = cache.get(key)
     if data is not None:return data
     data = func(*args, **kws)
     cache.set(key,data,timeout_seconds)
     if thread_cache is True:THREAD_CACHES[key] = data
     return data
示例#5
0
 def do_cache(*args, **kws):
     if isinstance(cache_key, str):
         key = cache_key
     elif callable(cache_key):
         key = cache_key(*args, **kws)
     if thread_cache is True:
         if THREAD_CACHES.has_key(cache_key):
             return THREAD_CACHES[cache_key]
     data = cache.get(key)
     if data is not None:
         return data
     data = func(*args, **kws)
     cache.set(key, data, timeout_seconds)
     if thread_cache is True:
         THREAD_CACHES[key] = data
     return data
示例#6
0
 def decorated_view(*args, **kwargs):
     slog = request.method,current_user.id,current_user.nickname,time.strftime("%Y-%m-%d %X", time.localtime()),request,request.form
     logging.error(slog)
     print slog
     clog = cache.get('johnlog')
     if not clog:
         print '99999999999999'
         cache.set('johnlog',slog)
     
     slog = cache.get('johnlog')
     print slog
     
     if not current_user.is_authenticated():
         return current_app.login_manager.unauthorized()
     if current_user.action(fn.__name__):
         return fn(*args, **kwargs)
     if request.is_xhr:return jsonify(result=False,error=u'权限不1足')
     abort(403)
示例#7
0
 def decorator(*args, **kwargs):
     response = cache.get(request.path)
     if response is None:
         response = f(*args, **kwargs)
         cache.set(request.path, response, self.timeout)
     return response
示例#8
0
 def decorator(*args, **kwargs):
     response = cache.get(request.path)
     if response is None:
         response = f(*args, **kwargs)
         cache.set(request.path, response, self.timeout)
     return response