jfinkels/flask-restless — pull request #162 by bpedman (2013-03-16 20:57:19+00:00)
Title: New preprocessor/postprocessor functions should permit None return type

I am testing out the latest changes to Flask-Restless so I can support association proxies in SQLAlchemy. However, the removal of the authentication function and switch to preprocessor functions is kind of frustrating.

I would like to have a single function that will enforce authentication for all of my API requests for GET, POST, PATCH, and DELETE. However, using the new preprocessor functions I have to return different values for each processor type. This makes it difficult to have just a single function for all of these HTTP methods since the processors are required to return different values.

For instance I will need to have different authentication functions for PATCH (single) and POST. The PATCH (single) function has to return the second argument to the function to be able to just show that nothing has changed, while the POST function has to return the first argument to show that nothing has changed. So basically I need 6 different authentication methods for each pre-processor type now instead of 1 and none of them are doing anything to the data.

I think the best fix for this would be that if any of the pre/post-processor functions return None (or maybe some other sentinel/special value) it would not alter the data at all. This would allow me to have a single authentication processor function that could be used for all HTTP methods.