[System] plugins can register a post install routine, for e.g. filling the database.
This commit is contained in:
parent
24418f5bcb
commit
251648e9a4
|
@ -50,7 +50,7 @@ def __load_plugins(app):
|
|||
app.config["FG_AUTH_BACKEND"] = plugin
|
||||
else:
|
||||
del plugin
|
||||
else:
|
||||
if plugin:
|
||||
app.config["FG_PLUGINS"][entry_point.name] = plugin
|
||||
if "FG_AUTH_BACKEND" not in app.config:
|
||||
logger.error("No authentication plugin configured or authentication plugin not found")
|
||||
|
@ -61,14 +61,18 @@ def install_all():
|
|||
|
||||
db.create_all()
|
||||
db.session.commit()
|
||||
installed = []
|
||||
for name, plugin in current_app.config["FG_PLUGINS"].items():
|
||||
if not plugin:
|
||||
logger.debug("Skip disabled plugin {}".format(name))
|
||||
continue
|
||||
logger.info("Install plugin {}".format(name))
|
||||
plugin.install()
|
||||
installed.append(plugin)
|
||||
if plugin.permissions:
|
||||
roleController.create_permissions(plugin.permissions)
|
||||
for plugin in installed:
|
||||
plugin.post_install()
|
||||
|
||||
|
||||
def create_app(test_config=None):
|
||||
|
|
|
@ -44,6 +44,12 @@ class Plugin:
|
|||
"""
|
||||
pass
|
||||
|
||||
def post_install(self):
|
||||
"""Fill database or do other stuff
|
||||
Called after all plugins are installed
|
||||
"""
|
||||
pass
|
||||
|
||||
def serialize(self):
|
||||
"""Serialize a plugin into a dict
|
||||
|
||||
|
|
Loading…
Reference in New Issue