def __init__(self, initial=None): handlers = initial or { 'application/json': JSONHandler(), 'application/json; charset=UTF-8': JSONHandler(), } # NOTE(jmvrbanac): Directly calling UserDict as it's not inheritable. # Also, this results in self.update(...) being called. UserDict.__init__(self, handlers)
from falcon_caching import Cache as BaseCache from falcon_limiter import Limiter from webargs import falconparser from mcod import settings from mcod.core.api import middlewares from mcod.core.api.converters import ExportFormatConverter, RDFFormatConverter from mcod.core.api.media import ExportHandler, RDFHandler, SparqlHandler, XMLHandler, ZipHandler from mcod.core.api.utils.json_encoders import APIEncoder from mcod.core.api.apm import get_client, get_data_from_request from mcod.core.utils import get_limiter_key from mcod.lib.errors import error_serializer, error_handler, error_404_handler, error_422_handler, error_500_handler logger = logging.getLogger("elasticapm.errors.client") jsonapi_handler = JSONHandler(dumps=partial(json.dumps, cls=APIEncoder)) extra_handlers = { # JSON:API 'application/vnd.api+json': jsonapi_handler, 'application/vnd.api+json; ext=bulk': jsonapi_handler, # XML 'application/xml': XMLHandler(), # other 'text/csv': ExportHandler(), 'text/tsv': ExportHandler(), 'text/tab-separated-values': ExportHandler(), 'application/vnd.ms-excel': ExportHandler(), 'application/sparql-results+json': SparqlHandler(), 'application/sparql-results+xml': SparqlHandler(), 'application/zip': ZipHandler()