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 from flaschengeist.system.hook import HookCall
send_message_hook = HookCall("send_message") send_message_hook = HookCall("send_message")
@ -7,7 +9,7 @@ class Plugin:
def __init__(self, config=None, blueprint=None, permissions={}): def __init__(self, config=None, blueprint=None, permissions={}):
self.blueprint = blueprint self.blueprint = blueprint
self.permissions = permissions self.permissions = permissions
self.version = "dummy" self.version = pkg_resources.get_distribution(self.__module__.split(".")[0]).version
def install(self): def install(self):
"""Installation routine """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") example_bp = Blueprint("example", __name__, url_prefix="/example")
permissions = {"EXAMPLE_HELLO": "example_hello"} permissions = {"EXAMPLE_HELLO": "example_hello"}
class PluginExample(Plugin):
def register(): def __init__(self, conf):
# If no model is needed: super().__init__(blueprint=example_bp, permissions=permissions)
# return Plugin(schedule_bp, permissions)
# else if model is used: def install(self):
class ExamplePlugin(Plugin): from flaschengeist.system.database import db
def install(self): import .model
from flaschengeist.system.database import db db.create_all()
import .model db.session.commit()
db.create_all()
db.session.commit()
@example_bp.route("/hello", methods=['GET'])
return ExamplePlugin(schedule_bp, permissions)
@schedule_bp.route("/hello", methods=['GET'])
@login_required(roles=['example_hello']) @login_required(roles=['example_hello'])
def __hello(id, **kwargs): def __hello(id, **kwargs):
return "Hello" return "Hello"
@ -94,8 +89,6 @@ Optional, only needed if you need your own models (database)
from flaschengeist.system.database import db from flaschengeist.system.database import db
model_name = __name__
class ExampleModel(db.Model): class ExampleModel(db.Model):
"""Example Model""" """Example Model"""
@ -115,7 +108,7 @@ Optional, only needed if you need your own models (database)
], ],
entry_points={ entry_points={
"flaschengeist.plugin": [ "flaschengeist.plugin": [
"example = flaschengeist-example-plugin:register" "roles = flaschengeist.modules.roles:register", "example = flaschengeist-example-plugin:ExampleModel"
] ]
}, },
) )