Skip to content
handlers.py 683 B
Newer Older
Antoine Millet's avatar
Antoine Millet committed
#!/usr/bin/env python
#coding:utf8

class RpcHandler(object):    
    '''
    Basic RPC functions handler.
    '''

    def __getitem__(self, name):
        if hasattr(self, name):
            return getattr(self, name)
        else:
            raise KeyError(name)


# Decorators:

def threadless(func):
    '''
    Function handler decorator -- don't spawn a new thread when function is
    called.
    '''
    
    func.__threaded__ = False
    return func

def pure(func):
    '''
    Function handler decorator -- the function is a pure fonction, caller will
    not pass :class:`RpcConnection` object in call parameters.
    '''
    
    func.__pure__ = True
    return func