-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a REST API #27
Comments
Which format then? JSON?
|
I think the format will be set by the http "ACCEPT" header. I'm thinking For instance, if the request comes with a ACCEPT: XML, the web service About how to do it, I'm thinking about different things. Currently, the But there is a way to change this and we can, rather than return The other solution would be to continue using the template renderer but I still have to dig a bit more into the APIs of Flask to see how this is Anyway, before finding out how it needs to be done, I think the need is
And that's it! Are there some specific things that we should take into account about |
Sure there's a way, we just need to investigate as I personally discovered Django recently and, as with Flask, I have absolutely no idea on how to make it render different things. Anyway I don't think the "by hand" solution is the way to go here. Ok with the draft of the interface definition of the WS, an exception though about the project deletion. And nope, I don't think about anything special required for Android especially... |
I gave it some more thoughts, and I now think that we should put the maximum of logic about the models into the models themselves, same for the forms. The views should stay really simple (a bit more than they currently are) and then it will be easy to impelment a REST API. I'm thinking that the end-user way to go should be with python decorators specifying the resource they are acting on, maybe the related model that comes from it and the rest could be directly built up by itself (well, we'll see if it's that easy) I'm thinking about something like this: @restify("/api/projects/")
and it would be easy to tweak the default behavior using methods named get, post etc. This means some refactoring but hopefully not too much as we already took care of the separation of the logic when we could (so everything is not at the same place). |
Well... I'm lost :D Huh |
I don't think going private is a good idea, as @fredericsureau and others would be interested to take part in the discussion. Why are you lost? What's unclear? Anyway, I'll probably go for the implementation of it and you'll probably understand more clearly ("talk is cheap, show me the code"). |
I meant, just for the part where you explain it to me more in deep :) But yeah, show me the code :) |
Introduces the "rest" module, with reusable utils for flask applications (will be packaged as a flask extension later on).
I've impemented basic stuff in the repository, that's under the modules What's missing is the creation and update of resources. It is possible to retrieve a list, an element and to delete stuff for now. The only serializer so far is the json one, and I think we should stick to it, nope? If we are in need of a XML serialization, I would be able to implement it quickly. |
From my point of view JSON is by far more pleasant to use so I'm happy you did it first :) Very good job by the way, I had no idea how this could be achieved at first, but everything became clear when reading your code. Edit: Maybe it's the good time to consider starting a doc? |
I've implemented creation and update as well. I'm +1 on a doc (I'm thinking about a way to auto-generate it), and I want to add some tests as well to be sure the code is working in all edge cases. |
All the things should be available trough a simple HTTP REST Interface.
The text was updated successfully, but these errors were encountered: