mirror of
https://github.com/veops/cmdb.git
synced 2025-08-07 11:28:06 +08:00
flask init-cache
This commit is contained in:
@@ -74,8 +74,6 @@ class AttributeValueManager(object):
|
||||
deserialize = type_map["deserialize"][value_type]
|
||||
try:
|
||||
v = deserialize(value)
|
||||
if isinstance(v, markupsafe.Markup):
|
||||
v = str(v)
|
||||
return v
|
||||
except ValueError:
|
||||
return abort(400, "attribute value <{0}> is invalid".format(value))
|
||||
|
@@ -1,5 +1,6 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import hashlib
|
||||
|
||||
@@ -11,7 +12,7 @@ from future.moves.urllib.parse import urlparse
|
||||
|
||||
|
||||
def build_api_key(path, params):
|
||||
g.user is not None or abort(403, u"您得登陆才能进行该操作")
|
||||
g.user is not None or abort(403, "您得登陆才能进行该操作")
|
||||
key = g.user.key
|
||||
secret = g.user.secret
|
||||
values = "".join([str(params[k]) for k in sorted(params.keys())
|
||||
|
@@ -1,6 +1,8 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from functools import wraps
|
||||
|
||||
import jwt
|
||||
@@ -20,7 +22,7 @@ def _auth_with_key():
|
||||
secret = request.values.get('_secret')
|
||||
path = request.path
|
||||
keys = sorted(request.values.keys())
|
||||
req_args = [request.values[k] for k in keys if str(k) not in ("_key", "_secret")]
|
||||
req_args = [request.values[k] for k in keys if k not in ("_key", "_secret")]
|
||||
user, authenticated = User.query.authenticate_with_key(key, secret, req_args, path)
|
||||
if user and authenticated:
|
||||
login_user(user)
|
||||
|
@@ -69,6 +69,6 @@ class RedisHandler(object):
|
||||
try:
|
||||
ret = self.r.hdel(self.prefix, key_id)
|
||||
if not ret:
|
||||
current_app.logger.warn("[%d] is not in redis".format(key_id))
|
||||
current_app.logger.warn("[{0}] is not in redis".format(key_id))
|
||||
except Exception as e:
|
||||
current_app.logger.error("delete redis key error, {0}".format(str(e)))
|
||||
|
Reference in New Issue
Block a user