[Doc] Some more documentation
This commit is contained in:
parent
425eb1c849
commit
2f9446be2f
|
@ -2,6 +2,9 @@ _hook_dict = {}
|
||||||
|
|
||||||
|
|
||||||
class Hook(object):
|
class Hook(object):
|
||||||
|
"""Decorator for Hooks
|
||||||
|
Use to decorate system hooks where plugins should be able to hook in
|
||||||
|
"""
|
||||||
def __init__(self, function):
|
def __init__(self, function):
|
||||||
self.function = function
|
self.function = function
|
||||||
|
|
||||||
|
@ -12,6 +15,7 @@ class Hook(object):
|
||||||
|
|
||||||
|
|
||||||
class HookCall(object):
|
class HookCall(object):
|
||||||
|
"""Decorator for functions to be called if a Hook is called"""
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,27 @@ from werkzeug.exceptions import MethodNotAllowed
|
||||||
from flaschengeist.hook import HookCall
|
from flaschengeist.hook import HookCall
|
||||||
|
|
||||||
send_message_hook = HookCall("send_message")
|
send_message_hook = HookCall("send_message")
|
||||||
|
"""Hook for sending messages, register to send the message
|
||||||
|
Args:
|
||||||
|
message: Message object to send
|
||||||
|
"""
|
||||||
|
|
||||||
update_user_hook = HookCall("update_user")
|
update_user_hook = HookCall("update_user")
|
||||||
|
"""When ever an user update is done, this is called before.
|
||||||
|
Args:
|
||||||
|
user: User object
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class Plugin:
|
class Plugin:
|
||||||
|
"""Base class for all Plugins"""
|
||||||
def __init__(self, config=None, blueprint=None, permissions=[]):
|
def __init__(self, config=None, blueprint=None, permissions=[]):
|
||||||
|
"""Constructor called by create_app
|
||||||
|
Args:
|
||||||
|
config: Dict configuration containing the plugin section
|
||||||
|
blueprint: A flask blueprint containing all plugin routes
|
||||||
|
permissions: List of permissions of this Plugin
|
||||||
|
"""
|
||||||
self.blueprint = blueprint
|
self.blueprint = blueprint
|
||||||
self.permissions = permissions
|
self.permissions = permissions
|
||||||
self.version = pkg_resources.get_distribution(self.__module__.split(".")[0]).version
|
self.version = pkg_resources.get_distribution(self.__module__.split(".")[0]).version
|
||||||
|
@ -20,6 +36,11 @@ class Plugin:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
|
"""Serialize a plugin into a dict
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Dict containing version and permissions of the plugin
|
||||||
|
"""
|
||||||
return {"version": self.version, "permissions": self.permissions}
|
return {"version": self.version, "permissions": self.permissions}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue