def handle_error_410_exception(error, request): """Add json body with explanation to 410 errors.""" context = request.context registry = request.registry reason = error.detail or "" explanation = view_blocked_by_metadata(context, registry, reason) schema = BlockExplanationResponseSchema().bind(request=request, context=context) cstruct = schema.serialize(explanation) if cstruct["modification_date"] is colander.null: cstruct["modification_date"] = "" json_error = JSONHTTPClientError([], request=request, code=error.code, title=error.title) json_error.json_body = cstruct return json_error
def handle_error_410_exception(error, request): """Add json body with explanation to 410 errors.""" from adhocracy_core.rest.schemas import BlockExplanationResponseSchema context = request.context registry = request.registry reason = error.detail or '' explanation = view_blocked_by_metadata(context, registry, reason) schema = create_schema(BlockExplanationResponseSchema, context, request) cstruct = schema.serialize(explanation) if cstruct['modification_date'] is null: cstruct['modification_date'] = '' json_error = JSONHTTPClientError([], request=request, code=error.code, title=error.title) json_error.json_body = cstruct return json_error
def call_fut(self, *args): from adhocracy_core.sheets.metadata import view_blocked_by_metadata return view_blocked_by_metadata(*args)