mara / mara-app

A framework for distributing flask apps across separate packages with minimal dependencies
MIT License
15 stars 4 forks source link

more pythonic way to construct the app #16

Closed ghost closed 6 years ago

ghost commented 7 years ago

Currently the creation of the apps and it's blueprints is intransparent: Ifa blueprint was importat in any way, it is added to the app. That leads to funny code which basically imports a lot of stuff but never uses it.

This has some problems:

I would therefore like to make the app creation explicit by reworking the individual MaraApp auto-register functions to take an explicit argument. To make it possible for other packages to change their stuff, these packages should expose a MARA_XXX = [<xx object>] list. The app creation process is then:

import mara_page
app = MaraApp()
app.register_blueprints(mara_page.MARA_BLUEPRINTS)
# or even this, which would look through the module and fetch all known 
# MARA_XXX and register them
app.register_package(mara_page)

This still keeps mara-app and mara-page completely independent

jacopofar commented 7 years ago

We switched to something similar, modules are now loaded based on the presence of the MARA_XXX keys for blueprints, click commands and so on, like this.

This is currently done by introspection over the loaded modules, we plan to move to an even more explicit declaration like the one you described.

martin-loetzsch commented 6 years ago

I think with the MARA_XXX module variables we have now something that is halfway between registering everything that was imported and register_package.