Files
ping-mee-self-service-platform/portal/adapters/registry.py
T
ebbe.bassandClaude Sonnet 5.5 20510a73e5 feat: add scheduler and mail outbox
SMTP adapter with TLS and a fake, outbox with retries, backoff, rate limit and restart safety, scheduler tick with job-run records started by gunicorn, and a send_test_mail command.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N3t4WL7bd9bdHHNjEsxzqC
2026-10-18 09:18:42 +02:00

43 lines
1.1 KiB
Python

"""Where the rest of the portal gets its adapters. Tests install fakes with `install`."""
from __future__ import annotations
from django.conf import settings
from .directory import Directory, LdapDirectory
from .idp import Idp, OidcIdp
from .mail import Mailer, SmtpMailer
_directory: Directory | None = None
_idp: Idp | None = None
_mailer: Mailer | None = None
def get_directory() -> Directory:
global _directory
if _directory is None:
_directory = LdapDirectory(settings.DIRECTORY)
return _directory
def get_idp() -> Idp:
global _idp
if _idp is None:
_idp = OidcIdp(settings.OIDC)
return _idp
def get_mailer() -> Mailer:
global _mailer
if _mailer is None:
_mailer = SmtpMailer(settings.SMTP)
return _mailer
def install(
directory: Directory | None = None, idp: Idp | None = None, mailer: Mailer | None = None
) -> None:
"""Replace the adapters (tests). Passing None for one leaves it to be built on first use."""
global _directory, _idp, _mailer
_directory, _idp, _mailer = directory, idp, mailer