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
log a warning or error when adding something to blueprint after adding it to application #2255
Comments
💯 This should be the case for any Blueprint addition (routes, listeners, middleware, exception handlers, signals). |
I might give this one a try tomorrow or on Monday |
Or better yet, make the blueprint changes work even after added to an app, if doing so is feasible. |
This could be a bit messy, and I believe would require a bit of a refactor from how the decorators work. I think it also breaks the principle of what the Blueprint is, but perhaps could be doable with something like this: def route(self, *args, **kwargs):
kwargs["apply"] = False
sup = super().route
def wrapper(handler):
retval = sup(*args, **kwargs)(handler)
for app in self.apps:
self.register(app, {})
return retval
return wrapper If we are going this direction, then we need to definitely beef up the unit testing around this, and probably make all of these methods (route, static, middleware, exception, signal) perhaps a little more DRY. |
@prryplatypus I am going to take this one myself. I hope you do not mind. |
All good! |
Is your feature request related to a problem? Please describe.
when i add a blueprint to the sanic app, and then add routes to it, those routes dont work. i have to add the blueprint to the app after adding routes. but there is no indication that im doing something wrong if i do it the wrong way
Describe the solution you'd like
log a warning or error message telling the programmer that they added routes to a blueprint after adding it to the app, and that those routes will not work. or straight up throw an error
The text was updated successfully, but these errors were encountered: