GET_MANY preprocessors accept a built-in search_params
dictionary, but GET_SINGLE ones only accept instance_id
. A kw**
arg is passed to all pre and postprocessors, but I've found that this is just for forwards compatibility, though this is somewhat unclear in the Flask-Restless docs:
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. This way, you can specify only the keyword arguments you need when defining your functions. Furthermore, if a new version of Flask-Restless changes the API, you can update Flask-Restless without breaking your code.
Is it then not possible to pass parameters other than instance_id
to a GET_SINGLE preprocessor?
EDIT
Perhaps there is a better way to do what I'm trying to do: I have two models, Foo
and Bar
. A record in Foo
stores as one of its columns a foreign key to a record in Bar
. I want a GET request sent to Foo
which specifies a value for the foreign key to return a single quasi-random record from the set of records in Foo
with a foreign key of the requested value.