smartrpyc.server.register
This module provides facilities for preparing a library of methods
to be exposed via the RPC.
The library creation can happen in several ways:
- Using a MethodsRegister decorator, to register a bunch
of stand-alone functions
- Usinng a MethodsObject to expose all the methods in a
given object (instance). This is especially useful if you need
to expose methods from an object instance, ie. you need to share
some state.
Base for the Method Register objects
This class provides an abstract of the methods that can (and should)
be exposed by a methods register object.
-
class smartrpyc.server.register.MethodsRegisterBase[source]
Base for the Method Register objects.
This class provides an abstract of the methods that can (and should)
be exposed by a methods register object.
-
list_methods()[source]
List all the supported methods
-
lookup(method)[source]
The most important method, returning the appropriate
method to be called.
-
register(func=None, name=None)[source]
Only used for registers supporting changes
Methods register
-
class smartrpyc.server.register.MethodsRegister[source]
Register for methods to be exposed via RPC.
Mostly a wrapper around a dict.
Usage:
methods = MethodsRegister()
@methods.register
def my_method(request, arg1, arg2):
pass
@methods.register(name='method2')
def my_other_method(request, arg1=123, arg2=None):
pass
methods.register(func=func, name='test')
# then pass methods to the Server() constructor
-
list_methods()[source]
-
lookup(method)[source]
-
register(func=None, name=None)[source]
Refer to class docstring
Params func: | Callable to register |
Params name: | Basestring to use as reference
name for func |
-
store(name, function)[source]
Method used to finally register a
function.
Params name: | Functions lookup name |
Params function: |
| Callable function |
Methods object
Note
I don’t like the name and I think I’ll change it soon.
-
class smartrpyc.server.register.MethodsObject[source]
Objects wrapper register.
This is a “wrapper” register, that automatically exposes all the methods
contained in the object passed to the constructor.
-
list_methods()[source]
-
lookup(method)[source]
-
set_object(obj)[source]