I saw How to use the context manager inside the decorator and how to pass the object created in the decorator to the decorated function , as well as python decorators with parameters , and I'm trying to combine the two ... but I'm struggling to get around it.
I would rather use the func tools @wrap tools to do this, if possible, since I know if the doc string will save.
I want to do the following:
def pyro_opener(func,service,database,port,secret_key): def wrapper(params): with Pyro4.Proxy("PYRO:"+service+"@"+database+":"+port) as obj: obj.set_secret_key(secret_key) return obj.func(params) return wrapper @pyro_opener(output_service, employee_db,port=9876,secret_key="h3llow0rld") def get_employee_names(salary): return obj.return_employee_names(salary)
I do not think this works like this, the return_employee_names method is on the service at the other end of the connection. Should I just return a function call? If so, how do I pass the parameters to ??
Pureferret
source share