74 lines
1.9 KiB
Python
74 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""
|
|
Configuration Package for MYP Platform
|
|
======================================
|
|
|
|
This package contains all configuration modules for the Mercedes-Benz 3D Printing Platform.
|
|
|
|
Modules:
|
|
- security: Security configuration and middleware
|
|
- database: Database configuration and settings
|
|
- logging: Logging configuration
|
|
- app_config: Main application configuration
|
|
"""
|
|
|
|
__version__ = "2.0.0"
|
|
__author__ = "MYP Development Team"
|
|
|
|
# Import main configuration modules
|
|
try:
|
|
from .security import SecurityConfig, get_security_headers
|
|
from .app_config import Config, DevelopmentConfig, ProductionConfig, TestingConfig
|
|
except ImportError as e:
|
|
print(f"Warning: Could not import configuration modules: {e}")
|
|
# Fallback configurations
|
|
SecurityConfig = None
|
|
get_security_headers = None
|
|
Config = None
|
|
|
|
# Export main configuration classes
|
|
__all__ = [
|
|
'SecurityConfig',
|
|
'get_security_headers',
|
|
'Config',
|
|
'DevelopmentConfig',
|
|
'ProductionConfig',
|
|
'TestingConfig'
|
|
]
|
|
|
|
def get_config(config_name='development'):
|
|
"""
|
|
Get configuration object based on environment name.
|
|
|
|
Args:
|
|
config_name (str): Configuration environment name
|
|
|
|
Returns:
|
|
Config: Configuration object
|
|
"""
|
|
configs = {
|
|
'development': DevelopmentConfig,
|
|
'production': ProductionConfig,
|
|
'testing': TestingConfig
|
|
}
|
|
|
|
return configs.get(config_name, DevelopmentConfig)
|
|
|
|
def validate_config(config_obj):
|
|
"""
|
|
Validate configuration object.
|
|
|
|
Args:
|
|
config_obj: Configuration object to validate
|
|
|
|
Returns:
|
|
bool: True if valid, False otherwise
|
|
"""
|
|
required_attrs = ['SECRET_KEY', 'DATABASE_URL']
|
|
|
|
for attr in required_attrs:
|
|
if not hasattr(config_obj, attr):
|
|
print(f"Missing required configuration: {attr}")
|
|
return False
|
|
|
|
return True |