Skip to content

Instantly share code, notes, and snippets.

@rodrigopr
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodrigopr/414e5311fb7ddb70effa to your computer and use it in GitHub Desktop.
Save rodrigopr/414e5311fb7ddb70effa to your computer and use it in GitHub Desktop.
Flask installable module draft
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()
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