-
Notifications
You must be signed in to change notification settings - Fork 8
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
Split api routes declaration #191
Conversation
I'll open an issue to reimplement all of Flask. Be quick, please. :P |
thanks to the utilities introduced in `webant/util.py` it is now passible to split routes declaration into multiple module This commit moved archivant related api routes in its own module.
|
||
from flask import Blueprint, current_app, jsonify | ||
from webant.util import add_routes | ||
from archivant_api import routes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this part is slightly counterintuitive: all this pull request is created so to make multiple modules adding routes to a single blueprint easier. But if you do from foo import routes
you can only do it one time.
So probably
import archivant_api
add_routes(api, archivant_api.routes)
would be easier
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On 10/04/2015 01:26 PM, BoySka wrote:
In webant/api/blueprint_api.py
#191 (comment):
self.err_code = err_code
self.message = message
- self.details = details
- def str(self):
- return "http_code: {}, err_code: {}, message: '{}', details: '{}'".format(self.http_code, self.err_code, self.message, self.details)
-def make_success_response(message, http_code=200):
- response = jsonify({'code': http_code, 'message': message})
- response.status_code = http_code
- return response
+from flask import Blueprint, current_app, jsonify
+from webant.util import add_routes
+from archivant_api import routesthis part is slightly counterintuitive: all this pull request is created
so to make multiple modules adding routes to a single blueprint easier.
But if you do |from foo import routes| you can only do it one time.
So probablyimport archivant_api
add_routes(api, archivant_api.routes)
would be easier
There are at least two solution to the problem you've raised:
- use the
as
keyword to differentiate the importedroutes
objects
(used by me inusers_api
branch) - the one that you suggested, import all module and specify later.
I think this is a minor issue and we can change it at the next api
implementation. It's a simple import problem, but if you want to change
it now you need only to choose the solution you like most.
9f2e804
to
59c8c85
Compare
In the meanwhile I've rebased to solve conflicts with latest commits on master branch |
Cause it's not possible to use nested blueprint (pallets/flask#593) I've implemented a simple pattern to split api routes declaration. From now on every api groups will reside in it's own module.
This will make easier/cleaner to implement users api.