tornado_restless.api – ApiManager¶
- class tornado_restless.api.ApiManager(application: tornado.web.Application, session_maker: type=None)[source]¶
The tornado restless engine
You normally only need one instance of this class to spawn your tornado routes
- __init__(application: tornado.web.Application, session_maker: type=None)[source]¶
Create an instance of the tornado restless engine
Parameters: - session_maker – is a sqlalchemy.orm.Session class factory
- application – is the tornado.web.Application object
- create_api(model, virtualhost='.*$', *args, **kwargs)[source]¶
Creates and registers a route for the model in your tornado application
The positional and keyword arguments are passed directly to the create_api_blueprint method
Parameters: - model –
- virtualhost – bindhost for binding, .*$ in default
- create_api_blueprint(model, methods: set=frozenset({'GET'}), preprocessor: dict=None, postprocessor: dict=None, url_prefix: str='/api', collection_name: str=None, allow_patch_many: bool=False, allow_method_override: bool=False, validation_exceptions=None, exclude_queries: bool=False, exclude_hybrids: bool=False, include_columns: list=None, exclude_columns: list=None, results_per_page: int=10, max_results_per_page: int=100, blueprint_prefix: str='', handler_class: type=<class 'tornado_restless.handler.BaseHandler'>) → tornado.web.URLSpec[source]¶
Create a tornado route for a sqlalchemy model
Parameters: - model – The sqlalchemy model
- methods – Allowed methods for this model
- url_prefix – The url prefix of the application
- collection_name –
- allow_patch_many – Allow PATCH with multiple datasets
- allow_method_override – Support X-HTTP-Method-Override Header
- validation_exceptions –
- exclude_queries – Don’t execude dynamic queries (like from associations or lazy relations)
- exclude_hybrids – When exclude_queries is True and exclude_hybrids is False, hybrids are still included.
- include_columns – Whitelist of columns to be included
- exclude_columns – Blacklist of columns to be excluded
- results_per_page – The default value of how many results are returned per request
- max_results_per_page – The hard upper limit of resutest per page
- blueprint_prefix – The Prefix that will be used to unique collection_name for named_handlers
- preprocessor – A dictionary of list of preprocessors that get called
- postprocessor – A dictionary of list of postprocessor that get called
- handler_class (tornado_restless.handler.BaseHandler or a subclass) – The Handler Class that will be used in the route
Returns: tornado.web.URLSpec
Raise: IllegalArgumentError