chub package¶
Submodules¶
chub.api module¶
this module has classes for converting python method calls to request on RESTful api
- class chub.api.API(base_url, async=True, api_version='v1', token=None, **kwargs)[source]¶
Bases: chub.api.Resource
API takes the base_url and a boolean async . Based on value of async an async or sync fetch function is set
- mappings = {}¶
- class chub.api.Accounts(base_url, async=True, api_version='v1', token=None, **kwargs)[source]¶
Bases: chub.api.API
API client for accounts service
- login(email, password)[source]¶
login using email and password :param email: email address :param password: password
- mappings = {'info': 'accounts.get', 'login': 'accounts.login.post', 'register_service': 'accounts.services.post'}¶
chub.handlers module¶
this module has some handler utilities for HTTP request and response
- class chub.handlers.ResponseObject[source]¶
Bases: dict
Access the value of in a dictionary by using the key as attribute. >>> obj = ResponseObject() >>> obj[‘foo’] = ‘bar’ >>> obj.foo ‘bar’
- chub.handlers.async_fetch(*args, **kwargs)[source]¶
fetch resource using the asynchronous AsyncHTTPClient :param request: HTTPRequest object or a url :param method: HTTP method in string format, e.g. GET, POST :param callback: callback function on the result. it is used by the coroutine decorator. :param kwargs: query string entities or POST data
- chub.handlers.convert(data)[source]¶
convert a standalone unicode string or unicode strings in a mapping or iterable into byte strings.
- chub.handlers.make_fetch_func(base_url, async, **kwargs)[source]¶
make a fetch function based on conditions of 1) async 2) ssl
- chub.handlers.make_request(request, method, default_headers=None, **kwargs)[source]¶
convert parameters into relevant parts of the an http request :param request: either url or an HTTPRequest object :param method: http request method :param default_headers: default headers :param kwargs: headers, query string params for GET and DELETE, data for POST and PUT
- chub.handlers.parse_response(response)[source]¶
parse response and return a dictionary if the content type. is json/application. :param response: HTTPRequest :return dictionary for json content type otherwise response body
- chub.handlers.sync_fetch(request, method, default_headers=None, httpclient=None, **kwargs)[source]¶
fetch resource using the synchronous HTTPClient :param request: HTTPRequest object or a url :param method: HTTP method in string format, e.g. GET, POST :param kwargs: query string entities or POST data
chub.oauth2 module¶
- class chub.oauth2.Delegate(resource_id, access)[source]¶
Bases: object
Object representing a delegate scope
- class chub.oauth2.RequestToken[source]¶
Bases: object
Function object for making token requests with simple caching of the responses
NOTE: errors are not cached
- max_cache_size = 100¶
- max_until_expired = 60¶