Skip to content
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

Make auto-routes optional #16

Open
apiguy opened this issue Jan 27, 2013 · 4 comments
Open

Make auto-routes optional #16

apiguy opened this issue Jan 27, 2013 · 4 comments

Comments

@apiguy
Copy link
Owner

apiguy commented Jan 27, 2013

@joeshaw mentioned he'd like to see it be possible to disable automatically generating routes. We need to figure out the correct api for this feature, be it a keyword arg passed in during registration of the FlaskView or an attribute of the FlaskView itself.

@maxcountryman
Copy link
Contributor

I suppose the most explicit and least surprising way to handle this is probably an attribute that can be set to override automatic routing over the class object:

class ClassyView(FlaskView):
    auto_route = False
    ...

@apiguy
Copy link
Owner Author

apiguy commented Jan 29, 2013

I like that idea, but what I worry about is setting a future precedent where configuration values each get their own class attribute, and then the nightmare of having subclasses override that functionality as well. I guess the decision I have to make is:

  1. Should there be some single attribute required for managing behavior configuration, or should there be an attribute for each configurable behavior?
  2. Should the attribute be inherited?

@maxcountryman
Copy link
Contributor

(1) I think you can safely provide them each as an attribute and perhaps use a naming scheme where the attributes are named with a leading underscore. That would minimize the chance of unintended collisions.

(2) The class that inherits FlaskView should define an attribute e.g. _auto_route = False. FlaskView should then be keeping an eye out for that flag. So the initial value would be defined on FlaskView as some default but could later be overloaded by the child class.

@SantjagoCorkez
Copy link

I think, there MUST be a single point for switching auto-route on/off application-wide, making the implicit FlaskView successors' attribute value the same as that point says. For example it could be an app.config key. Then one could override that app-wide value for only those classes he wants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants