"""
extensions.py
-------------
Flask "extensions" (add-on libraries) need to be created once, but are used
by many different files (models.py, routes in every blueprint, etc.).

If we created them directly inside app/__init__.py, every other file that
needed them would have to import from app/__init__.py — and app/__init__.py
itself imports those other files, which creates a "circular import" error.

The fix is simple: create the extension objects here, in their own small
file with no other dependencies. Every other file can safely import from
here without any circularity.
"""

from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager

# The database object. Models (in models.py) will inherit from db.Model.
db = SQLAlchemy()

# Handles "who is logged in" for both admins and players.
login_manager = LoginManager()

# If someone tries to view a page that needs login and isn't logged in,
# Flask-Login will send them to this route name automatically.
login_manager.login_view = "auth.login"
login_manager.login_message = "Please log in to view that page."
login_manager.login_message_category = "info"
