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

Document how to handle views in multiple different python files? #113

Open
almet opened this issue Mar 10, 2020 · 4 comments
Open

Document how to handle views in multiple different python files? #113

almet opened this issue Mar 10, 2020 · 4 comments
Labels

Comments

@almet
Copy link

almet commented Mar 10, 2020

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 !

@yohanboniface
Copy link
Member

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.py that would contain only the app and 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! :)

@almet
Copy link
Author

almet commented Mar 10, 2020

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 👍. If this can help anybody, it's as simple as what's described in this gist.

@almet almet closed this as completed Mar 10, 2020
@davidbgk
Copy link
Contributor

Hi :)

It might be worth a dedicated example in the docs? 🤔

@almet almet changed the title How to handle views in multiple different python files? Document how to handle views in multiple different python files? Mar 10, 2020
@almet
Copy link
Author

almet commented Mar 10, 2020

Right! Let's reopen this then :-)

@almet almet reopened this Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants