Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jxxghp committed Sep 14, 2024
1 parent f6c84a7 commit 57bad63
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/db/plugindata_oper.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def get_data(self, plugin_id: str, key: str = None) -> Any:
data = PluginData.get_plugin_data_by_key(self._db, plugin_id, key)
if not data:
return None
if ObjectUtils.is_obj(data.value):
if ObjectUtils.is_objstr(data.value):
return json.loads(data.value)
return data.value
else:
Expand Down
2 changes: 1 addition & 1 deletion app/db/systemconfig_oper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self):
"""
super().__init__()
for item in SystemConfig.list(self._db):
if ObjectUtils.is_obj(item.value):
if ObjectUtils.is_objstr(item.value):
self.__SYSTEMCONF[item.key] = json.loads(item.value)
else:
self.__SYSTEMCONF[item.key] = item.value
Expand Down
2 changes: 1 addition & 1 deletion app/db/userconfig_oper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self):
"""
super().__init__()
for item in UserConfig.list(self._db):
value = json.loads(item.value) if ObjectUtils.is_obj(item.value) else item.value
value = json.loads(item.value) if ObjectUtils.is_objstr(item.value) else item.value
self.__set_config_cache(username=item.username, key=item.key, value=value)

def set(self, username: str, key: Union[str, UserConfigKey], value: Any):
Expand Down
15 changes: 11 additions & 4 deletions app/utils/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@ def is_obj(obj: Any):
elif isinstance(obj, int) \
or isinstance(obj, float) \
or isinstance(obj, bool) \
or isinstance(obj, bytes):
or isinstance(obj, bytes) \
or isinstance(obj, str):
return False
else:
return str(obj).startswith("{") \
or str(obj).startswith("[")
return True

@staticmethod
def is_objstr(obj: Any):
if not isinstance(obj, str):
return False
return str(obj).startswith("{") \
or str(obj).startswith("[") \
or str(obj).startswith("(")

@staticmethod
def arguments(func: Callable) -> int:
Expand Down

0 comments on commit 57bad63

Please sign in to comment.