-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
more contexts in pre/postprocessors #619
Comments
Hi @tarekziade! This is probably a good idea. Access to the model class is an easy win. What other information might a preprocessor function need? My concern is that after adding a new keyword argument for the preprocessor, (then another, then another...), we may end up with an unwieldy user interface. Perhaps it makes sense to collect the information into a single object, maybe a |
Maybe the SA session and instance ?
Sounds like a good idea. Another option would be to pass the API instance directly maybe. Since it has all the mentioned info + more, like the primary_key etc |
@jfinkels One quick hack that does not require an API change is to add the API instance in flask.g |
This is my ugly and lame hack to make it work - I add in flask.g the api class : https://github.com/mozilla/servicebook/blob/master/servicebook/server.py#L19 Then my postprocessor can implement the 412 & 428 : https://github.com/mozilla/servicebook/blob/master/servicebook/server.py#L49 |
It would be great to have more context when a pre/postprocessor function is called.
Having access to the model class, and other info parsed by the manager would be very useful.
my use case is to implement the If-Modified header so I need to query the model and check a requests header before allowing a data change.
Happy to build a PR for this if needed
The text was updated successfully, but these errors were encountered: