flask-restless
flask-restless copied to clipboard
Add support routes for hybrid_methods
It would be nice for hybrid_methods to be available in a form something like this:
class Location():
@hybrid_method
def temperature(self, day):
return weather.temperature(self.zipcode, day)
# available in the API as:
/api/locations/:id/temperature?day=2016-01-01
# also potentially available in the API as a column on locations, which would then require that /locations/:id accept a day param
We're building out something like this on top of flask-restless, but if there was a pattern that would be accepted as a PR, we can build it that way instead. Is a Pull Request that implements the above pattern something that would be accepted?
Interesting. Flask-Restless will support the JSON API protocol in the next release; does this cause any problem with that? I'm not sure it makes sense to have a temperature
attribute when fetching a Location
resource, since the day
query parameter doesn't apply to the resource represented by the URL, it really applies to the temperature
resource.
I don't see any obvious reason why it couldn't work. Make sure your pull request has tests, probably in the tests/test_fetching.py
module.
I'm not sure about JSON API issues. Is there a branch or something we should test against? I agree that the example is not the best. Thanks
You will see when you clone the master branch that the code is very different from version 0.17.0.