def make_resource_handler(self, name, pattern, base_url, handler_class, model_class, collection_name, schema, is_capped_collection, capped_collection_size, id_field_name, timestamp_field_name, allow_get, allow_post, allow_put, allow_delete, accepted_mime, content_types_mime, **kwargs): # Prepare the DBlayer db_layer = self.get_db_layer(collection_name, id_field_name, timestamp_field_name, is_capped_collection, capped_collection_size) # Load classes if type(handler_class) in [str, unicode]: handler_class = load_class(handler_class) if type(model_class) in [str, unicode]: model_class = load_class(model_class) # Make the handler handler = ( tornado.web.URLSpec(base_url + pattern, handler_class, dict( dblayer=db_layer, Id=id_field_name, timestamp=timestamp_field_name, base_url=base_url+pattern, allow_delete=allow_delete, schemas_single=schema, model_class=model_class, collection_name=collection_name, **kwargs ), name=name ) ) return handler
def _make_main_handler(self, name, pattern, base_url, handler_class, resources): if type(handler_class) in [str, unicode]: handler_class = load_class(handler_class) main_handler = ( tornado.web.URLSpec(base_url + pattern, handler_class, dict( resources=resources, base_url=base_url+pattern, ), name=name ) ) return main_handler
def make_simple_handler(self, name, pattern, base_url, handler_class, **kwargs): if type(handler_class) in [str, unicode]: handler_class = load_class(handler_class) handler = ( tornado.web.URLSpec(base_url + pattern, handler_class, dict(**kwargs), name=name) ) return handler
def make_resource_handler(self, name, pattern, base_url, handler_class, model_class, collection_name, schema, is_capped_collection, capped_collection_size, id_field_name, timestamp_field_name, allow_get, allow_post, allow_put, allow_delete, accepted_mime, content_types_mime, **kwargs): """ Creates HTTP Request handler. Parameters: name: the name of the URL handler to be used with reverse_url. pattern: For example "/ports$" or "/ports/(?P<res_id>[^\/]*)$". The final URL of the resource is `base_url` + `pattern`. base_url: see pattern handler_class: The class handling this request. Must inherit `tornado.web.RequestHanlder` model_class: Database model class for this resource (if any). collection_name: The name of the database collection storing this resource. schema: Schemas fot this resource in the form: "{MIME_TYPE: SCHEMA}" is_capped_collection: If true the database collection is capped. capped_collection_size: The size of the capped collection (if applicable) id_field_name: name of the identifier field timestamp_field_name: name of the timestampe field allow_get: allow HTTP GET (True or False) allow_post: allow HTTP POST (True or False) allow_put: allow HTTP PUT (True or False) allow_delete: allow HTTP DELETE (True or False) accepted_mime: list of accepted MIME types content_types_mime: List of Content types that can be returned to the user kwargs: additional handler specific arguments """ # Load classes if type(handler_class) in [str, unicode]: handler_class = load_class(handler_class) if type(model_class) in [str, unicode]: model_class = load_class(model_class) # Prepare the DBlayer # Prepare the DBlayer db_layer = self.get_db_layer(collection_name, id_field_name, timestamp_field_name, is_capped_collection, capped_collection_size) # Make the handler handler = ( tornado.web.URLSpec(base_url + pattern, handler_class, dict( dblayer=db_layer, Id=id_field_name, timestamp=timestamp_field_name, base_url=base_url+pattern, allow_delete=allow_delete, schemas_single=schema, model_class=model_class, **kwargs ), name=name ) ) return handler
def make_auth_handler(self, name, pattern, base_url, handler_class, schema): if type(handler_class) in [str, unicode]: handler_class = load_class(handler_class) handler = ( tornado.web.URLSpec(base_url + pattern, handler_class, name=name) ) return handler