mirror of
https://github.com/sartography/spiffworkflow-backend.git
synced 2025-02-22 20:38:08 +00:00
updates to remove some deprecation warnings w/ burnettk
This commit is contained in:
parent
595a94a1b2
commit
8f44f36671
@ -7,8 +7,8 @@ function error_handler() {
|
||||
trap 'error_handler ${LINENO} $?' ERR
|
||||
set -o errtrace -o errexit -o nounset -o pipefail
|
||||
|
||||
if [[ -z "${FLASK_ENV:-}" ]]; then
|
||||
export FLASK_ENV=staging
|
||||
if [[ -z "${SPIFFWORKFLOW_BACKEND_ENV:-}" ]]; then
|
||||
export SPIFFWORKFLOW_BACKEND_ENV=staging
|
||||
fi
|
||||
|
||||
if [[ -z "${FLASK_SESSION_SECRET_KEY:-}" ]]; then
|
||||
|
@ -9,7 +9,7 @@ from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
||||
|
||||
def main(process_instance_id: str):
|
||||
"""Main."""
|
||||
os.environ["FLASK_ENV"] = "development"
|
||||
os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "development"
|
||||
flask_env_key = "FLASK_SESSION_SECRET_KEY"
|
||||
os.environ[flask_env_key] = "whatevs"
|
||||
app = create_app()
|
||||
|
@ -26,7 +26,7 @@ def print_process_instance_count(process_model_identifier_ticket: str) -> None:
|
||||
|
||||
def main():
|
||||
"""Main."""
|
||||
os.environ["FLASK_ENV"] = "development"
|
||||
os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "development"
|
||||
flask_env_key = "FLASK_SESSION_SECRET_KEY"
|
||||
os.environ[flask_env_key] = "whatevs"
|
||||
app = create_app()
|
||||
|
@ -43,7 +43,7 @@ mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_development
|
||||
mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_testing"
|
||||
|
||||
for task in $tasks; do
|
||||
FLASK_ENV=development FLASK_APP=src/spiffworkflow_backend poetry run flask db "$task"
|
||||
SPIFFWORKFLOW_BACKEND_ENV=development FLASK_APP=src/spiffworkflow_backend poetry run flask db "$task"
|
||||
done
|
||||
|
||||
FLASK_ENV=testing FLASK_APP=src/spiffworkflow_backend poetry run flask db upgrade
|
||||
SPIFFWORKFLOW_BACKEND_ENV=testing FLASK_APP=src/spiffworkflow_backend poetry run flask db upgrade
|
||||
|
@ -7,8 +7,8 @@ function error_handler() {
|
||||
trap 'error_handler ${LINENO} $?' ERR
|
||||
set -o errtrace -o errexit -o nounset -o pipefail
|
||||
|
||||
if [[ -z "${FLASK_ENV:-}" ]]; then
|
||||
export FLASK_ENV=development
|
||||
if [[ -z "${SPIFFWORKFLOW_BACKEND_ENV:-}" ]]; then
|
||||
export SPIFFWORKFLOW_BACKEND_ENV=development
|
||||
fi
|
||||
|
||||
if [[ -z "${BPMN_SPEC_ABSOLUTE_DIR:-}" ]]; then
|
||||
|
@ -10,7 +10,7 @@ from spiffworkflow_backend.services.spec_file_service import SpecFileService
|
||||
|
||||
def main():
|
||||
"""Main."""
|
||||
os.environ["FLASK_ENV"] = "development"
|
||||
os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "development"
|
||||
flask_env_key = "FLASK_SESSION_SECRET_KEY"
|
||||
os.environ[flask_env_key] = "whatevs"
|
||||
if "BPMN_SPEC_ABSOLUTE_DIR" not in os.environ:
|
||||
|
@ -33,7 +33,7 @@ from spiffworkflow_backend import create_app # noqa: E402
|
||||
@pytest.fixture(scope="session")
|
||||
def app() -> Flask:
|
||||
"""App."""
|
||||
os.environ["FLASK_ENV"] = "testing"
|
||||
os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "testing"
|
||||
# os.environ["FLASK_SESSION_SECRET_KEY"] = "this_is_testing_secret_key"
|
||||
os.environ["FLASK_SESSION_SECRET_KEY"] = "super_secret_key"
|
||||
app = create_app()
|
||||
|
@ -51,7 +51,7 @@ services:
|
||||
context: .
|
||||
environment:
|
||||
- APPLICATION_ROOT=/
|
||||
- FLASK_ENV=${FLASK_ENV:-development}
|
||||
- SPIFFWORKFLOW_BACKEND_ENV=${SPIFFWORKFLOW_BACKEND_ENV:-development}
|
||||
- FLASK_DEBUG=0
|
||||
- FLASK_SESSION_SECRET_KEY=${FLASK_SESSION_SECRET_KEY:-super_secret_key}
|
||||
- OPEN_ID_SERVER_URL=${OPEN_ID_SERVER_URL:-http://localhost:7002}
|
||||
|
@ -42,7 +42,7 @@ def setup_database(session: Session) -> None:
|
||||
flask_env_key = "FLASK_SESSION_SECRET_KEY"
|
||||
session.env[flask_env_key] = "super_secret_key"
|
||||
session.env["FLASK_APP"] = "src/spiffworkflow_backend"
|
||||
session.env["FLASK_ENV"] = "testing"
|
||||
session.env["SPIFFWORKFLOW_BACKEND_ENV"] = "testing"
|
||||
session.run("flask", "db", "upgrade")
|
||||
|
||||
|
||||
|
27
poetry.lock
generated
27
poetry.lock
generated
@ -717,15 +717,15 @@ docs = ["sphinx"]
|
||||
|
||||
[[package]]
|
||||
name = "flask-sqlalchemy"
|
||||
version = "2.5.1"
|
||||
description = "Adds SQLAlchemy support to your Flask application."
|
||||
version = "3.0.0"
|
||||
description = "Add SQLAlchemy support to your Flask application."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">= 2.7, != 3.0.*, != 3.1.*, != 3.2.*, != 3.3.*"
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[package.dependencies]
|
||||
Flask = ">=0.10"
|
||||
SQLAlchemy = ">=0.8.0"
|
||||
Flask = ">=2.2"
|
||||
SQLAlchemy = ">=1.4.18"
|
||||
|
||||
[[package]]
|
||||
name = "furo"
|
||||
@ -2170,7 +2170,7 @@ testing = ["func-timeout", "jaraco.itertools", "pytest (>=6)", "pytest-black (>=
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = ">=3.9,<3.11"
|
||||
content-hash = "f0f5c8611ec24f6e9be2b12f838b9177b7d701d439e2bec7cd99db4e27b6ff1e"
|
||||
content-hash = "1eab1f1107af25153136aef3ef6964ed25e449b6bc27cd42a47bf485e23d4d4f"
|
||||
|
||||
[metadata.files]
|
||||
alabaster = [
|
||||
@ -2447,8 +2447,8 @@ Flask-RESTful = [
|
||||
{file = "Flask_RESTful-0.3.9-py2.py3-none-any.whl", hash = "sha256:4970c49b6488e46c520b325f54833374dc2b98e211f1b272bd4b0c516232afe2"},
|
||||
]
|
||||
flask-sqlalchemy = [
|
||||
{file = "Flask-SQLAlchemy-2.5.1.tar.gz", hash = "sha256:2bda44b43e7cacb15d4e05ff3cc1f8bc97936cc464623424102bfc2c35e95912"},
|
||||
{file = "Flask_SQLAlchemy-2.5.1-py2.py3-none-any.whl", hash = "sha256:f12c3d4cc5cc7fdcc148b9527ea05671718c3ea45d50c7e732cceb33f574b390"},
|
||||
{file = "Flask-SQLAlchemy-3.0.0.tar.gz", hash = "sha256:b54939fd5f48184742b7d5b222d86983e233b43140c1071a36327353e86f3b56"},
|
||||
{file = "Flask_SQLAlchemy-3.0.0-py3-none-any.whl", hash = "sha256:741dabf0903569a89e4793667e25be5bb9581e614fa0eeb81a395cc7dee40c4b"},
|
||||
]
|
||||
furo = [
|
||||
{file = "furo-2022.9.29-py3-none-any.whl", hash = "sha256:559ee17999c0f52728481dcf6b1b0cf8c9743e68c5e3a18cb45a7992747869a9"},
|
||||
@ -2905,7 +2905,18 @@ py = [
|
||||
{file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"},
|
||||
]
|
||||
pyasn1 = [
|
||||
{file = "pyasn1-0.4.8-py2.4.egg", hash = "sha256:fec3e9d8e36808a28efb59b489e4528c10ad0f480e57dcc32b4de5c9d8c9fdf3"},
|
||||
{file = "pyasn1-0.4.8-py2.5.egg", hash = "sha256:0458773cfe65b153891ac249bcf1b5f8f320b7c2ce462151f8fa74de8934becf"},
|
||||
{file = "pyasn1-0.4.8-py2.6.egg", hash = "sha256:5c9414dcfede6e441f7e8f81b43b34e834731003427e5b09e4e00e3172a10f00"},
|
||||
{file = "pyasn1-0.4.8-py2.7.egg", hash = "sha256:6e7545f1a61025a4e58bb336952c5061697da694db1cae97b116e9c46abcf7c8"},
|
||||
{file = "pyasn1-0.4.8-py2.py3-none-any.whl", hash = "sha256:39c7e2ec30515947ff4e87fb6f456dfc6e84857d34be479c9d4a4ba4bf46aa5d"},
|
||||
{file = "pyasn1-0.4.8-py3.1.egg", hash = "sha256:78fa6da68ed2727915c4767bb386ab32cdba863caa7dbe473eaae45f9959da86"},
|
||||
{file = "pyasn1-0.4.8-py3.2.egg", hash = "sha256:08c3c53b75eaa48d71cf8c710312316392ed40899cb34710d092e96745a358b7"},
|
||||
{file = "pyasn1-0.4.8-py3.3.egg", hash = "sha256:03840c999ba71680a131cfaee6fab142e1ed9bbd9c693e285cc6aca0d555e576"},
|
||||
{file = "pyasn1-0.4.8-py3.4.egg", hash = "sha256:7ab8a544af125fb704feadb008c99a88805126fb525280b2270bb25cc1d78a12"},
|
||||
{file = "pyasn1-0.4.8-py3.5.egg", hash = "sha256:e89bf84b5437b532b0803ba5c9a5e054d21fec423a89952a74f87fa2c9b7bce2"},
|
||||
{file = "pyasn1-0.4.8-py3.6.egg", hash = "sha256:014c0e9976956a08139dc0712ae195324a75e142284d5f87f1a87ee1b068a359"},
|
||||
{file = "pyasn1-0.4.8-py3.7.egg", hash = "sha256:99fcc3c8d804d1bc6d9a099921e39d827026409a58f2a720dcdb89374ea0c776"},
|
||||
{file = "pyasn1-0.4.8.tar.gz", hash = "sha256:aef77c9fb94a3ac588e87841208bdec464471d9871bd5050a287cc9a475cd0ba"},
|
||||
]
|
||||
pycodestyle = [
|
||||
|
@ -41,7 +41,7 @@ pytest-flask = "^1.2.0"
|
||||
pytest-flask-sqlalchemy = "^1.1.0"
|
||||
psycopg2 = "^2.9.3"
|
||||
typing-extensions = "^4.3.0"
|
||||
connexion = {extras = [ "swagger-ui",], version = "^2.13.1"}
|
||||
connexion = {extras = [ "swagger-ui",], version = "^2"}
|
||||
lxml = "^4.9.1"
|
||||
marshmallow-enum = "^1.5.1"
|
||||
marshmallow-sqlalchemy = "^0.28.0"
|
||||
@ -53,7 +53,7 @@ APScheduler = "^3.9.1"
|
||||
types-requests = "^2.28.6"
|
||||
Jinja2 = "^3.1.2"
|
||||
RestrictedPython = "^5.2"
|
||||
Flask-SQLAlchemy = "^2.5.1"
|
||||
Flask-SQLAlchemy = "^3"
|
||||
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
|
@ -14,11 +14,11 @@ def setup_database_uri(app: Flask) -> None:
|
||||
if os.environ.get("SPIFF_DATABASE_TYPE") == "sqlite":
|
||||
app.config[
|
||||
"SQLALCHEMY_DATABASE_URI"
|
||||
] = f"sqlite:///{app.instance_path}/db_{app.env}.sqlite3"
|
||||
] = f"sqlite:///{app.instance_path}/db_{app.config['ENV_IDENTIFIER']}.sqlite3"
|
||||
elif os.environ.get("SPIFF_DATABASE_TYPE") == "postgres":
|
||||
app.config[
|
||||
"SQLALCHEMY_DATABASE_URI"
|
||||
] = f"postgresql://spiffworkflow_backend:spiffworkflow_backend@localhost:5432/spiffworkflow_backend_{app.env}"
|
||||
] = f"postgresql://spiffworkflow_backend:spiffworkflow_backend@localhost:5432/spiffworkflow_backend_{app.config['ENV_IDENTIFIER']}"
|
||||
else:
|
||||
# use pswd to trick flake8 with hardcoded passwords
|
||||
db_pswd = os.environ.get("DB_PASSWORD")
|
||||
@ -26,7 +26,7 @@ def setup_database_uri(app: Flask) -> None:
|
||||
db_pswd = ""
|
||||
app.config[
|
||||
"SQLALCHEMY_DATABASE_URI"
|
||||
] = f"mysql+mysqlconnector://root:{db_pswd}@localhost/spiffworkflow_backend_{app.env}"
|
||||
] = f"mysql+mysqlconnector://root:{db_pswd}@localhost/spiffworkflow_backend_{app.config['ENV_IDENTIFIER']}"
|
||||
else:
|
||||
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get(
|
||||
"SPIFFWORKFLOW_BACKEND_DATABASE_URI"
|
||||
@ -41,10 +41,11 @@ def setup_config(app: Flask) -> None:
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
app.config['ENV_IDENTIFIER'] = os.environ.get("SPIFFWORKFLOW_BACKEND_ENV", "development")
|
||||
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
|
||||
app.config.from_object("spiffworkflow_backend.config.default")
|
||||
# This allows config/testing.py or instance/config.py to override the default config
|
||||
if "ENV" in app.config and app.config["ENV"] == "testing":
|
||||
if "SPIFFWORKFLOW_BACKEND_ENV" in app.config and app.config["SPIFFWORKFLOW_BACKEND_ENV"] == "testing":
|
||||
app.config.from_pyfile("config/testing.py", silent=True)
|
||||
else:
|
||||
app.config.from_pyfile(f"{app.instance_path}/config.py", silent=True)
|
||||
@ -52,7 +53,7 @@ def setup_config(app: Flask) -> None:
|
||||
setup_database_uri(app)
|
||||
setup_logger(app)
|
||||
|
||||
env_config_module = "spiffworkflow_backend.config." + app.env
|
||||
env_config_module = "spiffworkflow_backend.config." + app.config['ENV_IDENTIFIER']
|
||||
try:
|
||||
app.config.from_object(env_config_module)
|
||||
except ImportStringError as exception:
|
||||
|
@ -26,38 +26,6 @@ admin_blueprint = Blueprint(
|
||||
ALLOWED_BPMN_EXTENSIONS = {"bpmn", "dmn"}
|
||||
|
||||
|
||||
@admin_blueprint.before_app_first_request
|
||||
def before_first_request() -> None:
|
||||
"""Before_first_request."""
|
||||
# token()
|
||||
# ProcessInstanceReportModel.add_fixtures()
|
||||
|
||||
|
||||
# @admin_blueprint.route("/token", methods=["GET"])
|
||||
# def token() -> str:
|
||||
# """Token."""
|
||||
# if current_app.env == "production":
|
||||
# return "Not authorized"
|
||||
#
|
||||
# user = UserModel.query.first()
|
||||
# if user is None:
|
||||
# user = UserModel(service='keycloak',
|
||||
# service_id="test_user1",
|
||||
# name='Test Name',
|
||||
# username='test_username')
|
||||
# db.session.add(user)
|
||||
# db.session.commit()
|
||||
#
|
||||
# principal = PrincipalModel.query.filter_by(user_id=user.id).first()
|
||||
# if principal is None:
|
||||
# principal = PrincipalModel(user_id=user.id)
|
||||
# db.session.add(principal)
|
||||
# db.session.commit()
|
||||
#
|
||||
# auth_token = user.encode_auth_token()
|
||||
# return f"auth_token: {auth_token}"
|
||||
|
||||
|
||||
@admin_blueprint.route("/process-groups", methods=["GET"])
|
||||
def process_groups_list() -> str:
|
||||
"""Process_groups_list."""
|
||||
|
@ -22,7 +22,7 @@ class AuthorizationService:
|
||||
principal_ids = [p.id for p in principals]
|
||||
permission_assignment = (
|
||||
PermissionAssignmentModel.query.
|
||||
filter(PrincipalModel.id.in_(principal_ids))
|
||||
filter(PermissionAssignmentModel.principal_id.in_(principal_ids))
|
||||
.filter_by(
|
||||
permission=permission
|
||||
)
|
||||
|
@ -118,7 +118,7 @@ def setup_logger(app: Flask) -> None:
|
||||
|
||||
# the json formatter is nice for real environments but makes
|
||||
# debugging locally a little more difficult
|
||||
if app.env != "development":
|
||||
if app.config['ENV_IDENTIFIER'] != "development":
|
||||
json_formatter = JsonFormatter(
|
||||
{
|
||||
"level": "levelname",
|
||||
@ -136,7 +136,7 @@ def setup_logger(app: Flask) -> None:
|
||||
spiff_logger_filehandler = None
|
||||
if app.config["SPIFFWORKFLOW_BACKEND_LOG_TO_FILE"]:
|
||||
spiff_logger_filehandler = logging.FileHandler(
|
||||
f"{app.instance_path}/../../log/{app.env}.log"
|
||||
f"{app.instance_path}/../../log/{app.config['ENV_IDENTIFIER']}.log"
|
||||
)
|
||||
spiff_logger_filehandler.setLevel(spiff_log_level)
|
||||
spiff_logger_filehandler.setFormatter(log_formatter)
|
||||
|
@ -115,7 +115,7 @@ class CustomBpmnScriptEngine(PythonScriptEngine): # type: ignore
|
||||
|
||||
def __get_augment_methods(self, task: SpiffTask) -> Dict[str, Callable]:
|
||||
"""__get_augment_methods."""
|
||||
return Script.generate_augmented_list(task, current_app.env)
|
||||
return Script.generate_augmented_list(task, current_app.config['ENV_IDENTIFIER'])
|
||||
|
||||
def evaluate(self, task: SpiffTask, expression: str) -> Any:
|
||||
"""Evaluate."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user