Commit 67387faf authored by Jordi Riera's avatar Jordi Riera
Browse files

Back to **config.

parent ccfe2eb1
...@@ -16,32 +16,23 @@ from tweepy.models import Model ...@@ -16,32 +16,23 @@ from tweepy.models import Model
re_path_template = re.compile('{\w+}') re_path_template = re.compile('{\w+}')
def bind_api(api, def bind_api(**config):
# common practice to avoid the bug when a list is in arguments.
allowed_param = allowed_param or []
class APIMethod(object): class APIMethod(object):
path = path api = config['api']
payload_type = payload_type path = config['path']
payload_list = payload_list payload_type = config.get('payload_type', None)
allowed_param = allowed_param payload_list = config.get('payload_list', False)
method = method allowed_param = config.get('allowed_param', [])
require_auth = require_auth method = config.get('method', 'GET')
search_api = search_api require_auth = config.get('require_auth', False)
use_cache = use_cache search_api = config.get('search_api', False)
use_cache = config.get('use_cache', True)
session = requests.Session() session = requests.Session()
api = api
def __init__(self, args, kwargs): def __init__(self, args, kwargs):
api = self.api
# If authentication is required and no credentials # If authentication is required and no credentials
# are provided, throw an error. # are provided, throw an error.
if self.require_auth and not api.auth: if self.require_auth and not api.auth:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment