I have a class defined as this:
class ClientAPi
def __init__(self, host):
self.host = host
def foo(self, foo):
return self._foo(foo)
@property
def _foo(self):
return bind_api(
api=self,
path='/foo',
allowed_param=['foo'])
where bind_api is https://github.com/tweepy/tweepy/blob/master/tweepy/binder.py actually.. this is the pattern in tweepy library https://github.com/tweepy/tweepy/blob/master/tweepy/api.py
How does this works? I am unable to understand the flow.. I mean how does the variable foo is transmitted from foo() to _foo()..?
Also, now.. some of the paths for my api has changed..
instead of host:port/foo
now it is host:port/v1/foo
Is there a way I can annotate these methods with some decorator..such that methods which have this decorator has its path='/foo'
to path=/v1/foo
So for example
class ClientAPi
def __init__(self, host):
self.host = host
def foo(self, foo):
return self._foo(foo)
@new_api('v1')
@property
def _foo(self):
return bind_api(
api=self,
path='/foo',
allowed_param=['foo'])
changes path from '/foo'
to '/v1/foo'