flask-restless
flask-restless copied to clipboard
Is it possible to get instance_id in the DELETE_SINGLE_POSTPROCESSOR?
I have a case where I notify an external service when an object is deleted. I can be reasonably sure that it will succeed in the preprocessor, but I'd like to be absolutely sure and thus prefer to do it in the postprocessor.
Or is there another approach that I'm missing?
Thanks for a great product!
You are asking about the most recent stable version, 0.17.0, I believe. Unfortunately, I have made a major rewrite of the project to support JSON API, so I won't be able to fix this for that version. However, your suggestion still makes sense, so I'm taking this as a feature request for the development version (i.e. the master branch) as well.
As a workaround for version 0.17.0, you can patch the code manually by changing line 1394 in views.py
https://github.com/jfinkels/flask-restless/blob/0.17.0/flask_restless/views.py#L1394 from
postprocessor(was_deleted=was_deleted)
to
postprocessor(instance_id=instid, relation_name=relationname, relation_instance_id=relationinstid)
Then, when you define your postprocessor function, you can specify the same keyword arguments:
def my_cool_postprocessor(was_deleted=False, instance_id=None, **kw):
...