Document how to handle views in multiple different python files?
Hi (hope you're doing great !), and thanks for the project, love it so far :-) I'm trying to find a way to split the views in different python files, but as the views are all relying on the app, I'm not sure how to do it.
In the Flask project, they're using an intermediate concept named Blueprints for this, and I believe what I'm looking for seems similar.
Did you already face this issue? Any idea on how do deal with this? Thanks !
Hey @almet ! :)
There is nothing formal like blueprints included in Roll so far. We did discuss this needs (mainly from the "generical roll app" point of view), but for now didn't get the simple and generic solution to handle that.
IIRC, the option we evaluated was to have a route that would point to another app.
So you're stuck with plain python :p
Until now, I've myself used those structures:
- either a plain file with app and views
- either a
base.py(or core.py or…) that would be the entry point, with the app, maybe some views, and importing views from other "subfiles" (where other files are just for keeping the code base organized) - either a
base.pythat would contain only theappand it's configuration, then many views files dedicated to various needs, that would be then imported from the__init__.py(or any other intermediate to prevent those to be imported at install)
Hope it helps! :)
Hey, thanks for the quick response, and for the pointers.
Turns out my python started to be a bit rusty, and I managed to do what I wanted thanks to your help :+1:. If this can help anybody, it's as simple as what's described in this gist.
Hi :)
It might be worth a dedicated example in the docs? 🤔
Right! Let's reopen this then :-)