Skip to content

Commit

Permalink
enable deserialization in jsonrpc
Browse files Browse the repository at this point in the history
  • Loading branch information
cosven committed Aug 25, 2024
1 parent e1e87ec commit 2dfe110
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions feeluown/webserver/jsonrpc_.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from jsonrpc import JSONRPCResponseManager, Dispatcher

from feeluown.fuoexec.fuoexec import fuoexec_get_globals
from feeluown.serializers import serialize
from feeluown.serializers import serialize, deserialize


class DynamicDispatcher(Dispatcher):
Expand All @@ -12,24 +12,20 @@ def __getitem__(self, key):
return self.method_map[key]
except KeyError:
method = eval(key, fuoexec_get_globals())
return method


def deserialize(obj):
pass
return method_wrapper(method)


def method_wrapper(func):
@wraps(func)
def wrapper(*args, **kwargs):
new_args = ()
if args:
new_args = deserialize(args)
new_args = [deserialize('python', arg) for arg in args]
new_kwargs = {}
if kwargs:
new_kwargs = {}
for k, v in kwargs.items():
new_kwargs[k] = deserialize(v)
new_kwargs[k] = deserialize('python', v)
return func(*new_args, **new_kwargs)
return wrapper

Expand Down

0 comments on commit 2dfe110

Please sign in to comment.