config
This module contains both Flask configuration and application constants for Downtime Panda.
exports
- Config: Configuration class for the Downtime Panda application.
- TestingConfig: Configuration class for testing environment.
Config
Configuration class for the Downtime Panda application. This class holds configuration settings such as debug mode, database URL, and secret key.
Source code in src\downtime_panda\config.py
DEBUG = os.getenv('DTPANDA_DEBUG', 'false').lower() in ('true', '1', 'yes')
class-attribute
instance-attribute
Indicates whether the application is running in debug mode. Set to True if the environment variable 'DTPANDA_DEBUG' is set to 'true', '1', or 'yes' (case-insensitive).
SCHEDULER_JOBSTORES = {'default': SQLAlchemyJobStore(url=SQLALCHEMY_DATABASE_URI if os.getenv('DTPANDA_DB_URL') else 'sqlite:///src/instance/dtpanda.db', tablename='apscheduler_jobs')}
class-attribute
instance-attribute
Configuration for the APScheduler job store.
SCHEDULER_TIMEZONE = pytz.utc
class-attribute
instance-attribute
The timezone used by the APScheduler. Set to UTC by default.
SECRET_KEY = os.getenv('DTPANDA_SECRET_KEY') or 'a_very_secret_key'
class-attribute
instance-attribute
The secret key used by Flask for cryptographic operations (e.g., session signing). Loaded from the environment variable 'DTPANDA_SECRET'.
SQLALCHEMY_DATABASE_URI = f'postgresql+psycopg://{os.getenv('DTPANDA_DB_URL')}' if os.getenv('DTPANDA_DB_URL') else 'sqlite:///dtpanda.db'
class-attribute
instance-attribute
The database connection URL for the database, constructed from the environment variable 'DTPANDA_DB_URL'.
Defaults to a SQLite database file named dtpanda.db
if the environment variable is not set, which is saved inside the src/instance
directory.
TestingConfig
Bases: Config
Configuration class for testing environment. Inherits from Config and overrides specific settings for testing.
Source code in src\downtime_panda\config.py
DEBUG = True
class-attribute
instance-attribute
Enables debug mode for testing.
SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'
class-attribute
instance-attribute
Uses an in-memory SQLite database for testing purposes. This allows for fast tests without needing a persistent database.
TESTING = True
class-attribute
instance-attribute
Indicates that the application is in testing mode. This can enable additional testing features or behaviors.
WTF_CSRF_ENABLED = False
class-attribute
instance-attribute
Disables CSRF protection for testing. This is often done in tests to simplify form submissions.