def validate_body_or_querystring(body, qs: dict, schema: MappingSchema, context: IResource, request: Request): """Validate the querystring if this is a GET request, the body otherwise. This allows using just a single schema for all kinds of requests. """ if isinstance(schema, GETPoolRequestSchema): try: schema = add_arbitrary_filter_nodes(qs, schema, context, request.registry) except Invalid as err: # pragma: no cover _add_colander_invalid_error_to_request(err, request, location="querystring") if request.method.upper() == "GET": _validate_schema(qs, schema, request, location="querystring") else: _validate_schema(body, schema, request, location="body")
def validate_body_or_querystring(body, qs: dict, schema: MappingSchema, context: IResource, request: Request): """Validate the querystring if this is a GET request, the body otherwise. This allows using just a single schema for all kinds of requests. """ if isinstance(schema, GETPoolRequestSchema): try: schema = add_arbitrary_filter_nodes(qs, schema, context, request.registry) except Invalid as err: # pragma: no cover _add_colander_invalid_error_to_request(err, request, location='querystring') if request.method.upper() == 'GET': _validate_schema(qs, schema, request, location='querystring') else: _validate_schema(body, schema, request, location='body')
def call_fut(self, *args): from adhocracy_core.rest.schemas import add_arbitrary_filter_nodes return add_arbitrary_filter_nodes(*args)