flaschengeist/flaschengeist
Ferdinand Thiessen f03314efac Split installation and app creation. Added Readme 2020-10-15 14:44:58 +02:00
..
modules Split installation and app creation. Added Readme 2020-10-15 14:44:58 +02:00
system Fixed uncaught exception in auth and wrong example config 2020-10-15 12:05:16 +02:00
__init__.py Cleanup. Move old controller, removed unused code. 2020-09-07 18:11:38 +02:00
app.py Split installation and app creation. Added Readme 2020-10-15 14:44:58 +02:00
flaschengeist.example.cfg Fixed uncaught exception in auth and wrong example config 2020-10-15 12:05:16 +02:00
logging.yml Cleanup. Move old controller, removed unused code. 2020-09-07 18:11:38 +02:00
readme.md Split installation and app creation. Added Readme 2020-10-15 14:44:58 +02:00

readme.md

Flaschengeist

Installation

Requirements

  • mysql or mariadb
  • python 3.4+

Install python files

pip3 install --user .

or with ldap support

pip3 install --user ".[ldap]"

Configuration

  1. Rename flaschengeist.example.cfg to flaschengeist.cfg
  2. Move it to either
    1. the module path (where flaschegeist is installed)
    2. ~/.config/
    3. A custom path and set environment variable FLASCHENGEIST_CONF
  3. Change at least the database parameters

Database installation

run_flaschengeist --install

Run

run_flaschengeist

or with debug messages:

run_flaschengeist --debug

Plugin Development

File Structure

flaschengeist-example-plugin
 |> __init__.py
 |> model.py
 |> setup.py

Files

__init__.py

from flask import Blueprint
from flaschengeist.modules import Plugin

    
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'])
@login_required(roles=['example_hello'])
def __hello(id, **kwargs):
    return "Hello"

model.py

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"""
    __tablename__ = 'example'
    id = db.Column(db.Integer, primary_key=True)
    description = db.Column(db.String(240))

setup.py

from setuptools import setup, find_packages

setup(
    name="flaschengeist-example-plugin",
    version="0.0.0-dev",
    packages=find_packages(),
    install_requires=[
        "flaschengeist >= 2",
    ],
    entry_points={
        "flaschengeist.plugin": [
            "example = flaschengeist-example-plugin:register"            "roles = flaschengeist.modules.roles:register",
        ]
    },
)