def disable(method): """Decorator/function to disable RPC on a method.""" if is_classmethod(method) or is_bound(method): setattr(method.__func__, _rpc_enabled_attr, False) # for bound methods, we can only set attributes on the underlying function object else: setattr(method, _rpc_enabled_attr, False) # NOTE this will fail if applied on an instancemethod return method
def disable(method): """Decorator/function to disable RPC on a method.""" if is_classmethod(method) or is_bound(method): setattr( method.__func__, _rpc_enabled_attr, False ) # for bound methods, we can only set attributes on the underlying function object else: setattr(method, _rpc_enabled_attr, False) # NOTE this will fail if applied on an instancemethod return method
def enable(method, payload_attr=None): """Decorator/function to enable RPC on a method.""" #logger.debug("method: {}, type: {}, callable? {}, isfunction? {}, ismethod? {}, is_bound? {}, is_classmethod? {}".format(method, type(method), callable(method), isfunction(method), ismethod(method), is_bound(method), is_classmethod(method))) # [verbose] if is_classmethod(method) or is_bound(method): setattr(method.__func__, _rpc_enabled_attr, True) # for bound methods, we can only set attributes on the underlying function object if payload_attr is not None: setattr(method.__func__, payload_attr, True) else: setattr(method, _rpc_enabled_attr, True) # NOTE this will fail if applied on an instancemethod if payload_attr is not None: setattr(method, payload_attr, True) return method
def enable(method, payload_attr=None): """Decorator/function to enable RPC on a method.""" #logger.debug("method: {}, type: {}, callable? {}, isfunction? {}, ismethod? {}, is_bound? {}, is_classmethod? {}".format(method, type(method), callable(method), isfunction(method), ismethod(method), is_bound(method), is_classmethod(method))) # [verbose] if is_classmethod(method) or is_bound(method): setattr( method.__func__, _rpc_enabled_attr, True ) # for bound methods, we can only set attributes on the underlying function object if payload_attr is not None: setattr(method.__func__, payload_attr, True) else: setattr(method, _rpc_enabled_attr, True) # NOTE this will fail if applied on an instancemethod if payload_attr is not None: setattr(method, payload_attr, True) return method