Last active
August 29, 2015 14:21
-
-
Save rodrigopr/414e5311fb7ddb70effa to your computer and use it in GitHub Desktop.
Flask installable module draft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Resource(object): | |
def __init__(self, path, type): ... | |
def install(self, destination_map): ... | |
class ExModule(FlaskModule): | |
@property | |
def blueprints(self): | |
return [app, admin] | |
@property | |
def resoures(self): | |
return [ | |
Resource('templates/*', type=TEMPLATE), | |
Resource('scss/*', type=SCSS), | |
Resource('static/*', type=STATIC) | |
] | |
def init(self, flask_app): | |
load_authorization_rules() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app = flask.Flask() | |
destination_map = { | |
TEMPLATE: 'templates/', | |
SCSS: 'static/scss/', | |
STATIC: 'static/' | |
} | |
installed_modules = ['jusbrasil.admin', 'jusbrasil.layout', 'jusbrasil.ui'] | |
for m in installed_modules: | |
module = load_module(m) | |
for blueprint in module.blueprints: | |
app.register_blueprint(blueprint) | |
for resource in module.resources: | |
resource.install(destination_map) | |
module.init(app) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment