SIDEL_ScriptsManager/app/config/config.py

103 lines
2.9 KiB
Python

import os
from pathlib import Path
# Base directory for the project
BASE_DIR = Path(__file__).parent.parent.parent
class Config:
"""Base configuration class."""
# Database Configuration
SQLALCHEMY_DATABASE_URI = os.getenv(
"DATABASE_URL", f"sqlite:///{BASE_DIR}/data/scriptsmanager.db"
)
SQLALCHEMY_TRACK_MODIFICATIONS = False
# Application Settings
SECRET_KEY = os.getenv("SECRET_KEY", "your-secret-key-change-in-production")
DEBUG = os.getenv("DEBUG", "False").lower() == "true"
# Multi-user Settings
BASE_DATA_PATH = Path(os.getenv("BASE_DATA_PATH", "./data"))
MAX_PROJECTS_PER_USER = int(os.getenv("MAX_PROJECTS_PER_USER", "50"))
# Port Management
PORT_RANGE_START = int(os.getenv("PORT_RANGE_START", "5200"))
PORT_RANGE_END = int(os.getenv("PORT_RANGE_END", "5400"))
# Backup Configuration
BACKUP_ENABLED = os.getenv("BACKUP_ENABLED", "True").lower() == "true"
BACKUP_SCHEDULE_TIME = os.getenv("BACKUP_SCHEDULE_TIME", "02:00")
BACKUP_RETENTION_DAYS = int(os.getenv("BACKUP_RETENTION_DAYS", "30"))
# Conda Environment
CONDA_AUTO_DETECT = os.getenv("CONDA_AUTO_DETECT", "True").lower() == "true"
# Supported Languages
SUPPORTED_LANGUAGES = ["en", "es", "it", "fr"]
DEFAULT_LANGUAGE = os.getenv("DEFAULT_LANGUAGE", "en")
# Web Interface Management
WEB_INTERFACE_CONFIG = {
"port_range": {"start": PORT_RANGE_START, "end": PORT_RANGE_END},
"session_timeout": 1800,
"heartbeat_interval": 30,
"cleanup_interval": 300,
"max_concurrent_interfaces": 20,
"max_interfaces_per_user": 5,
}
# Documentation Settings
DOCUMENTATION_CONFIG = {
"markdown_extensions": ["codehilite", "tables", "toc", "math"],
"supported_languages": SUPPORTED_LANGUAGES,
"default_language": DEFAULT_LANGUAGE,
"enable_math_rendering": True,
"enable_diagram_rendering": False,
}
# Tagging Configuration
TAGGING_CONFIG = {
"max_tags_per_script": 20,
"max_tag_length": 30,
"allowed_tag_chars": "alphanumeric_underscore_dash",
"enable_tag_suggestions": True,
}
# Security Settings
SECURITY_CONFIG = {
"data_directory_permissions": "755",
"config_file_permissions": "644",
"enable_project_sharing": False,
"admin_can_access_all_data": True,
}
class DevelopmentConfig(Config):
"""Development configuration."""
DEBUG = True
class ProductionConfig(Config):
"""Production configuration."""
DEBUG = False
class TestingConfig(Config):
"""Testing configuration."""
TESTING = True
DATABASE_URL = "sqlite:///:memory:"
# Configuration dictionary
config = {
"development": DevelopmentConfig,
"production": ProductionConfig,
"testing": TestingConfig,
"default": DevelopmentConfig,
}