46 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| from datetime import timedelta
 | |
| from config.settings import settings
 | |
| 
 | |
| class Config:
 | |
|     """Configuration de base"""
 | |
|     SECRET_KEY = settings.SECRET_KEY
 | |
|     SQLALCHEMY_DATABASE_URI = settings.DATABASE_URL
 | |
|     SQLALCHEMY_TRACK_MODIFICATIONS = False
 | |
|     WTF_CSRF_TIME_LIMIT = timedelta(seconds=settings.WTF_CSRF_TIME_LIMIT)
 | |
|     DEBUG = settings.DEBUG
 | |
|     LOG_LEVEL = settings.LOG_LEVEL
 | |
|     
 | |
| class DevelopmentConfig(Config):
 | |
|     """Configuration pour le développement"""
 | |
|     DEBUG = settings.DEBUG
 | |
|     SQLALCHEMY_ECHO = settings.DB_ECHO
 | |
| 
 | |
| class ProductionConfig(Config):
 | |
|     """Configuration pour la production"""
 | |
|     DEBUG = False
 | |
|     SQLALCHEMY_ECHO = False
 | |
|     
 | |
|     @classmethod
 | |
|     def init_app(cls, app):
 | |
|         Config.init_app(app)
 | |
|         
 | |
|         # Log vers stderr en production
 | |
|         import logging
 | |
|         from logging import StreamHandler
 | |
|         file_handler = StreamHandler()
 | |
|         file_handler.setLevel(logging.WARNING)
 | |
|         app.logger.addHandler(file_handler)
 | |
| 
 | |
| class TestingConfig(Config):
 | |
|     """Configuration pour les tests"""
 | |
|     TESTING = True
 | |
|     SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'
 | |
|     WTF_CSRF_ENABLED = False
 | |
|     DEBUG = True
 | |
| 
 | |
| config = {
 | |
|     'development': DevelopmentConfig,
 | |
|     'production': ProductionConfig,
 | |
|     'testing': TestingConfig,
 | |
|     'default': DevelopmentConfig
 | |
| } |