Detect version of plugins from setup.py, updated Readme

This commit is contained in:
Ferdinand Thiessen 2020-10-19 13:16:23 +02:00
parent 233660d452
commit 28b202cf30
2 changed files with 16 additions and 21 deletions

View File

@ -1,3 +1,5 @@
import pkg_resources
from flaschengeist.system.hook import HookCall
send_message_hook = HookCall("send_message")
@ -7,7 +9,7 @@ class Plugin:
def __init__(self, config=None, blueprint=None, permissions={}):
self.blueprint = blueprint
self.permissions = permissions
self.version = "dummy"
self.version = pkg_resources.get_distribution(self.__module__.split(".")[0]).version
def install(self):
"""Installation routine

View File

@ -68,23 +68,18 @@ Or if you just want to use `git blame`, configure git like this:
example_bp = Blueprint("example", __name__, url_prefix="/example")
permissions = {"EXAMPLE_HELLO": "example_hello"}
def register():
# If no model is needed:
# return Plugin(schedule_bp, permissions)
# else if model is used:
class ExamplePlugin(Plugin):
def install(self):
from flaschengeist.system.database import db
import .model
db.create_all()
db.session.commit()
return ExamplePlugin(schedule_bp, permissions)
@schedule_bp.route("/hello", methods=['GET'])
class PluginExample(Plugin):
def __init__(self, conf):
super().__init__(blueprint=example_bp, permissions=permissions)
def install(self):
from flaschengeist.system.database import db
import .model
db.create_all()
db.session.commit()
@example_bp.route("/hello", methods=['GET'])
@login_required(roles=['example_hello'])
def __hello(id, **kwargs):
return "Hello"
@ -94,8 +89,6 @@ Optional, only needed if you need your own models (database)
from flaschengeist.system.database import db
model_name = __name__
class ExampleModel(db.Model):
"""Example Model"""
@ -115,7 +108,7 @@ Optional, only needed if you need your own models (database)
],
entry_points={
"flaschengeist.plugin": [
"example = flaschengeist-example-plugin:register" "roles = flaschengeist.modules.roles:register",
"example = flaschengeist-example-plugin:ExampleModel"
]
},
)