Newer
Older
#!/usr/bin/env python
#coding:utf8
class RpcHandler(object):
'''
Basic RPC functions handler.
Derive this call in your handler and define some methods. All the defined
methods (including privates) are available to your peer.
'''
def __getitem__(self, name):
if hasattr(self, name):
return getattr(self, name)
else:
raise KeyError(name)
def threadless(func):
'''
Function handler decorator -- don't spawn a new thread when function is
called.
'''
def pure(func):
'''
Function handler decorator -- the function is a pure fonction, caller will
not pass :class:`RpcConnection` object as first call parameters.
This decorator is useless since the default behavior have change. You
can use :func:`pass_connection` decorator to do the opposite.
This function is kept for compatibility only, and will be removed latter.
'''
return func
def pass_connection(func):
'''
Function handler decorator -- pass on first parameter the connection which
called this function.
'''
func.__pass_connection__ = True
return func
def pass_rpc(func):
Function handler decorator -- pass on first (or after connection) the
rpc protocol which called this function.
'''
func.__pass_rpc__ = True