class devilry.rest.restview.RestView(restapicls, apiname, apiversion, suffix_to_content_type_map={'xml': 'application/xml', 'yaml': 'application/yaml', 'json': 'application/json', 'html': 'text/html', 'extjs.json': 'application/extjsjson'}, input_data_preprocessors=[], output_data_postprocessors=[<function extjs at 0x10d6a05f0>], output_content_type_detectors=[<function devilry_accept_querystringparam at 0x10d697de8>, <function suffix at 0x10d6975f0>, <function from_acceptheader at 0x10d697d70>], input_content_type_detectors=[<function from_content_type_header at 0x10d697140>, <function use_output_content_type at 0x10d6971b8>], inputdata_handlers=[<function getqrystring_inputdata_handler at 0x10d697f50>, <function rawbody_inputdata_handler at 0x10d6a0050>], dataconverters={'application/extjsjson': <class 'devilry.dataconverter.jsondataconverter.JsonDataConverter'>, 'application/json': <class 'devilry.dataconverter.jsondataconverter.JsonDataConverter'>, 'application/yaml': <class 'devilry.dataconverter.yamldataconverter.YamlDataConverter'>, 'text/html': <class 'devilry.dataconverter.htmldataconverter.HtmlDataConverter'>, 'application/xml': <class 'devilry.dataconverter.xmldataconverter.XmlDataConverter'>}, restmethod_routers=[<function post_to_create at 0x10d6a0140>, <function get_with_id_to_read at 0x10d6a01b8>, <function put_with_id_to_update at 0x10d6a02a8>, <function delete_to_delete at 0x10d6a0398>, <function get_without_id_to_list at 0x10d6a0230>, <function put_without_id_to_batch at 0x10d6a0320>], response_handlers=[<function stricthttp at 0x10d6a00c8>])[source]¶
Django view that handles input/output to devilry.rest.restbase.RestBase.
Parameters:
restapicls – A class implementing devilry.rest.restbase.RestBase.
suffix_to_content_type_map – Maps suffix to content type. Used to determine content-type from url-suffix.
input_data_preprocessors –
List of input data post-processor callbacks. The callbacks have the following signature:
match,data=f(request,output_data)
The data of the first matching callback will be used. If no processor matches,
the unchanged data will be used.
Together with output_data_postprocessors this allows for wrapping
certain content-types with extra data. Example of use is to add data that is required
by a javascript library, such as the successful attribute required by ExtJS.
output_data_postprocessors – List of input data post-processor callbacks. See input_data_preprocessors
for more details. Note that the callbacks take one additional argument, a boolean
telling if the restful method completed without error.
output_content_type_detectors –
Input content type detectors detect the content type of the request data.
Must be a list of callables with the following signature:
content_type=f(request,suffix)
The first content_type that is not bool(content_type)==False will
be used.
input_content_type_detectors –
Similar to output_content_type_detectors, except for input/request
instead of for output/response. Furthermore, the the callbacks take the
output content-type as the third argument:
The first input data handler returning match==True is be used.
See devilry.rest.inputdata_handlers for implementations.
Input data can come in many different formats and from different sources.
Examples are such XML in request body, query string and JSON embedded in
a query string parameter.
dataconverters –
A dict of implementations of devilry.dataconverter.dataconverter.DataConverter.
The key is a content-type. Data converters convert between python and some other format,
such as JSON or XML.
Typically used by input_datahandlers and response_handlers to convert data
input the content_type detected by one of the output_content_type_detectors.