From 5a05b4af9df8bd59eab88ec34789923fd3dafc56 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sun, 25 Nov 2012 08:20:39 +0100 Subject: [PATCH] jsonrpc: Doc diff between wrapper and inspector --- mopidy/utils/jsonrpc.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mopidy/utils/jsonrpc.py b/mopidy/utils/jsonrpc.py index 78f1c2b3..23f50580 100644 --- a/mopidy/utils/jsonrpc.py +++ b/mopidy/utils/jsonrpc.py @@ -15,11 +15,6 @@ class JsonRpcWrapper(object): processing of JSON-RPC 2.0 messages. The transport of the messages over HTTP, WebSocket, TCP, or whatever is of no concern to this class. - Only the public methods of the objects will be exposed. Attributes are not - exposed by themself, but public methods on public attributes are exposed, - using dotted paths from the exposed object to the method at the end of the - path. - To expose a single object, add it to the objects mapping using the empty string as the key:: @@ -42,6 +37,11 @@ class JsonRpcWrapper(object): hello -> lambda abc.def -> abc.def() + Only the public methods of the objects will be exposed. Attributes are not + exposed by themself, but public methods on public attributes are exposed, + using dotted paths from the exposed object to the method at the end of the + path. + If a method returns a :class:`pykka.Future`, the future will be completed and its value unwrapped before the JSON-RPC wrapper returns the response. @@ -298,7 +298,7 @@ class JsonRpcInspector(object): To inspect a single class, add it to the objects mapping using the empty string as the key:: - jri = JsonRpcInspector(objects={'': MyClas}) + jri = JsonRpcInspector(objects={'': MyClass}) To inspect multiple classes, add them all to the objects mapping. The key in the mapping is used as the classes' mounting point in the exposed API:: @@ -309,6 +309,14 @@ class JsonRpcInspector(object): 'abc': Abc, }) + Since this inspector is based on inspecting classes and not instances, it + will not give you a complete picture of what is actually exported by + :class:`JsonRpcWrapper`. In particular: + + - it will not include methods added dynamically, and + - it will not include public methods on attributes on the instances that + are to be exposed. + :param objects: mapping between mounts and exposed functions or classes :type objects: dict """