nicolaiarocci/eve — pull request #195 by joshvillbrandt (2013-11-25 05:13:54+00:00)
Title: Modifies the GET behavior on list resources to adhere to HTTP standards

Modifies the GET behavior on list resources to adhere to HTTP standards when the If-Modified-Since header is present

Previously, eve would return a partial document list if only some documents had been modified since the time present in an If-Modified-Since header. However, the correct response should be to return all documents (200) or no documents (304) only. Returning a partial set is not an option. See issue #190 for more information.

To implement this fix, I do a preflight query leaving req.if_modified_since in place with a limit of 1 sorted by date. (This query effectively answers the question "has anything been modified since this date?") By placing this check in methods/get.py, the same 304 response behavior will exist regardless of data layer.

I would prefer, however, to entirely remove the code in io/mongo/mongo.py that checks for req.if_modified_since since I'm not sure if other HTTP verbs/methods rely on req.if_modified_since. But to do so, I'd have to modify the where argument of the request, and since the query arguments aren't parsed before the data layer and since multiple where argument formats are allowed, this would have been difficult or at the very least redundant. (Redundant if I parse the where clause, modified it, re-stringify and then the data layer would once again re-parse it.)

On that note, I'd suggest moving argument parsing out of the data layer and into utils.py/parse_request(). By placing argument parsing in the data layer as currently implemented, the possibility exists for data layers to interpret arguments differently. I imagine the preferred response is to support and enforce the same query syntax regardless of the data layer. Issue #194 has been opened to relay this request.