Me and a buddy have been reading through the docs for Flask-RESTless and it says:
The arguments to the preprocessor and postprocessor functions will be provided as keyword arguments, so you should always add **kw as the final argument when defining a preprocessor or postprocessor function.
but it doesn't specify how we can use these keyword argument to pass info to the pre- or postprocessor. Can anyone tell us how to do this?
Our create_api looks like this right now:
create_api(Foo,
methods=['GET', 'POST', 'PUT', 'DELETE'],
collection_name='p',
url_prefix='/api/v1',
primary_key='uid',
exclude_columns=['id'],
preprocessors={
'POST': [authenticate, validation_preprocessor],
'GET_SINGLE': [authenticate],
'GET_MANY': [authenticate],
'PUT_SINGLE': [authenticate, validation_preprocessor],
'PUT_MANY': [authenticate, validation_preprocessor],
'DELETE': [authenticate]
})
def validation_preprocessor(data=None, **kw):
# Do stuff
pass
What we want to do is use **kw in validation_preprocessor for our own values.