I have encountered an interesting scenario, while creating decorator in python. Following is my code :-
class RelationShipSearchMgr(object):
@staticmethod
def user_arg_required(obj_func):
def _inner_func(**kwargs):
if "obj_user" not in kwargs:
raise Exception("required argument obj_user missing")
return obj_func(*tupargs, **kwargs)
return _inner_func
@staticmethod
@user_arg_required
def find_father(**search_params):
return RelationShipSearchMgr.search(Relation.RELATION_FATHER, **search_params)
As shown in above code, I have created a decorator(which is static method in class), which checks, if "obj_user" is passed as argument to decorated function. I have decorated function find_father
, but I am getting following error message :- 'staticmethod' object is not callable
.
How to use static utility method as shown above, as decorator in python ?
Thanks in advance.