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

Removing blueprints and middleware #581

Closed
espositofulvio opened this issue Mar 23, 2017 · 9 comments
Closed

Removing blueprints and middleware #581

espositofulvio opened this issue Mar 23, 2017 · 9 comments

Comments

@espositofulvio
Copy link

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?

@subyraman
Copy link
Contributor

I'm pretty sure Flask does not allow you to do this. What is your use case?

@espositofulvio
Copy link
Author

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.

@seemethere
Copy link
Member

@espositofulvio You would like to do that dynamically?

@espositofulvio
Copy link
Author

Yeap, but I guess I can do that with the dispatcher extension or something similar, using application as I would do for Blueprints.
Thanks ;)

@hashgupta
Copy link
Contributor

Should we close this?

@ashleysommer
Copy link
Member

ashleysommer commented Apr 18, 2017

@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.
Do you think an unregister_application would be needed in Dispatcher to help with this?
FYI, in case you were having problems I recently updated the extension to work with Sanic v0.5/0.5.1

@espositofulvio
Copy link
Author

@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.

@ashleysommer
Copy link
Member

@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.

@espositofulvio
Copy link
Author

@ashleysommer I've seen your update, this can actually change my plans but I'm opening an issue in sanic-dispatcher to further discuss.

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

6 participants