mozilla-services/cornice — pull request #36 by rfk (2012-02-16 02:04:00+00:00)
Title: Allow multiple service view declarations for each HTTP method.

It would be awesome if I could do something like this in syncserver and get the 406-handling for free::

@collection.get(accept="application/json")
@collection.get(accept="application/newlines", renderer="newlines")
def get_collection(request):
return ["list", "of", "items"]

This *almost* works out of the box, but not quite. Unfortunately cornice assumes that there's only a single view definition for each HTTP method, e.g. when it uses self.definitions[request.method] to look up the kwargs. This prevents using the full power of pyramid's view predicates when declaring services.

This patch offers one possible approach, by making self.definitions just a list of api_kwargs that were declared. Not sure how that will interact with the auto-generated documentation though.