This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
devicehub-teal/ereuse_devicehub/teal/config.py

71 lines
2.1 KiB
Python
Raw Normal View History

2023-03-21 11:08:13 +00:00
from boltons.typeutils import issubclass
from ereuse_devicehub.teal.resource import Resource
class Config:
"""
The configuration class.
Subclass and set here your config values.
"""
2023-03-27 08:55:26 +00:00
RESOURCE_DEFINITIONS = set()
2023-03-21 11:08:13 +00:00
"""
A list of resource definitions to load.
"""
2023-03-27 08:55:26 +00:00
SQLALCHEMY_DATABASE_URI = None
2023-03-21 11:08:13 +00:00
"""
The access to the main Database.
"""
2023-03-27 08:55:26 +00:00
SQLALCHEMY_BINDS = {}
2023-03-21 11:08:13 +00:00
"""
Optional extra databases. See `here <http://flask-sqlalchemy.pocoo.org
/2.3/binds/#referring-to-binds>`_ how bind your models to different
databases.
"""
SQLALCHEMY_TRACK_MODIFICATIONS = False
"""
2023-03-27 08:55:26 +00:00
Disables flask-sqlalchemy notification system.
2023-03-21 11:08:13 +00:00
Save resources and hides a warning by flask-sqlalchemy itself.
2023-03-27 08:55:26 +00:00
2023-03-21 11:08:13 +00:00
See `this answer in Stackoverflow for more info
2023-03-27 08:55:26 +00:00
<https://stackoverflow.com/a/33790196>`_.
2023-03-21 11:08:13 +00:00
"""
API_DOC_CONFIG_TITLE = 'Teal'
API_DOC_CONFIG_VERSION = '0.1'
"""
Configuration options for the api docs. They are the parameters
passed to `apispec <http://apispec.readthedocs.io/en/
latest/api_core.html#apispec.APISpec>`_. Prefix the configuration
names with ``API_DOC_CONFIG_``.
"""
API_DOC_CLASS_DISCRIMINATOR = None
"""
Configuration options for the api docs class definitions.
2023-03-27 08:55:26 +00:00
2023-03-21 11:08:13 +00:00
You can pass any `schema definition <https://github.com/OAI/
OpenAPI-Specification/blob/master/versions/2.0.md#schemaObject>`_
prefiex by ``API_DOC_CLASS_`` like in the example above.
"""
CORS_ORIGINS = '*'
CORS_EXPOSE_HEADERS = 'Authorization'
CORS_ALLOW_HEADERS = 'Content-Type', 'Authorization'
"""
2023-03-27 08:55:26 +00:00
Configuration for CORS. See the options you can pass by in `Flask-Cors
2023-03-21 11:08:13 +00:00
<https://flask-cors.corydolphin.com/en/latest/api.html#extension>`_,
exactly in **Parameters**, like the ones above.
"""
def __init__(self) -> None:
"""
:param db: Optional. Set the ``SQLALCHEMY_DATABASE_URI`` param.
"""
for r in self.RESOURCE_DEFINITIONS:
assert issubclass(
r, Resource
), '{0!r} is not a subclass of Resource'.format(r)