Compare commits
No commits in common. "3fc04c4143564d3b1c678e23d73ec3a6b2a4f4a5" and "7b5f854d510c65c8b9932f48cf255a5dc257a47c" have entirely different histories.
3fc04c4143
...
7b5f854d51
|
@ -69,12 +69,7 @@ def configure_app(app, test_config=None):
|
|||
config["DATABASE"]["engine"] = "sqlite"
|
||||
|
||||
if config["DATABASE"]["engine"] == "mysql":
|
||||
engine = "mysql"
|
||||
try:
|
||||
# Try mysqlclient first
|
||||
from MySQLdb import _mysql
|
||||
except ModuleNotFoundError:
|
||||
engine += "+pymysql"
|
||||
engine = "mysql" + ("+pymysql" if os.name == "nt" else "")
|
||||
options = "?charset=utf8mb4"
|
||||
elif config["DATABASE"]["engine"] == "postgres":
|
||||
engine = "postgresql+psycopg2"
|
||||
|
|
98
readme.md
98
readme.md
|
@ -3,14 +3,9 @@ This is the backend of the Flaschengeist.
|
|||
|
||||
## Installation
|
||||
### Requirements
|
||||
- `mysql` or `mariadb`
|
||||
- maybe `libmariadb` development files[1]
|
||||
- python 3.7+
|
||||
|
||||
[1] By default Flaschengeist uses mysql as database backend, if you are on Windows Flaschengeist uses `PyMySQL`, but on
|
||||
Linux / Mac the faster `mysqlclient` is used, if it is not already installed installing from pypi requires the
|
||||
development files for `libmariadb` to be present on your system.
|
||||
|
||||
- mysql or mariadb
|
||||
- including development files libmariadb-dev
|
||||
- python 3.6+
|
||||
### Install python files
|
||||
pip3 install --user .
|
||||
or with ldap support
|
||||
|
@ -74,4 +69,89 @@ Or with html output (open `htmlcov/index.html` in a browser):
|
|||
$ coverage html
|
||||
|
||||
## Development
|
||||
Please refer to our [development wiki](https://flaschengeist.dev/Flaschengeist/flaschengeist/wiki/Development).
|
||||
### Code Style
|
||||
We enforce you to use PEP 8 code style with a line length of 120 as used by Black.
|
||||
See also [Black Code Style](https://github.com/psf/black/blob/main/docs/the_black_code_style/current_style.md).
|
||||
|
||||
#### Code formatting
|
||||
We use [Black](https://github.com/psf/black) as the code formatter.
|
||||
|
||||
Installation:
|
||||
|
||||
pip install black
|
||||
Usage:
|
||||
|
||||
black -l 120 DIRECTORY_OR_FILE
|
||||
|
||||
### Misc
|
||||
#### Git blame
|
||||
When using `git blame` use this to ignore the code formatting commits:
|
||||
|
||||
$ git blame FILE.py --ignore-revs-file .git-blame-ignore-revs
|
||||
Or if you just want to use `git blame`, configure git like this:
|
||||
|
||||
$ git config blame.ignoreRevsFile .git-blame-ignore-revs
|
||||
|
||||
#### Ignore changes on config
|
||||
git update-index --assume-unchanged flaschengeist/flaschengeist.toml
|
||||
|
||||
## 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"]
|
||||
|
||||
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"
|
||||
|
||||
#### model.py
|
||||
Optional, only needed if you need your own models (database)
|
||||
|
||||
from flaschengeist.system.database import db
|
||||
|
||||
|
||||
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:ExampleModel"
|
||||
]
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue