-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Removing blueprints and middleware #581
Comments
I'm pretty sure Flask does not allow you to do this. What is your use case? |
I was thinking of using Blueprints as loadable module of a web app, so I can easily switch on and off a blog section adding and removing the corresponding blueprint. |
@espositofulvio You would like to do that dynamically? |
Yeap, but I guess I can do that with the dispatcher extension or something similar, using application as I would do for Blueprints. |
Should we close this? |
@espositofulvio Did you use the dispatcher extension? I am the author and I was wondering what use-cases people might find for it. And loadable modules is one use-case that I like. |
@ashleysommer in the end I didn't. I have a requirements whereby an application can handle multiple websites (which can run on different/multiple domains) with different configurations, and the websites can be added/removed dinamically, so in the end I had to write my own framework. By the way, I tried the dispatcher extension last week and it didn't work with the latest sanic, a few things changed in the area of the request class. unregister_application would be a nice addition though, that would make using application as modules which a user can load/onload on demand. Just to make an example, think about a CMS where the paid feature is defined as an application, but you want to load/unload it only if a user paid for the extra. That would be easily done registering/unregistering an application. |
@espositofulvio you are right, latest Sanic broke a few of my plugins but they have all since been updated to work with 0.5.0 and 0.5.1 including Dispatcher. Yes, a CMS with loadable modules is a good use case that I also had in mind for Dispatcher, I might see if I can make a proof-of-concept for it in the future. |
@ashleysommer I've seen your update, this can actually change my plans but I'm opening an issue in sanic-dispatcher to further discuss. |
Hi,
I was wondering why there's no way to remove an entire blueprint or middleware from an application object. I can obviously work around that doing the cleanup myself but I'd love to have remove_blueprint and remove_middleware as the pair add_route/remove_route. Also, reading the code in app.py there's a member called _blueprint_order which appears to be a list of blueprints in insertion order but I can't find any other reference to that symbol, is that still needed?
The text was updated successfully, but these errors were encountered: