Notifications Internal Modules
These pages expose the implementation pieces behind notification delivery: selectors, queue adapters, rendering modes, and payload construction.
Cache adapter
codex_django.notifications.adapters.cache_adapter
DjangoCacheAdapter
ContentCacheAdapter implementation using BaseDjangoRedisManager.
A thin infrastructure shim — the caching strategy (key naming, TTL, invalidation) lives in BaseEmailContentSelector, not here.
Usage::
cache_adapter = DjangoCacheAdapter()
value = cache_adapter.get("my:cache:key")
cache_adapter.set("my:cache:key", "value", timeout=3600)
Classes
DjangoCacheAdapter
Notification content cache adapter backed by Redis.
Source code in src/codex_django/notifications/adapters/cache_adapter.py
21 22 23 24 25 26 27 28 29 30 31 32 | |
Functions
get(key)
Return a cached content value by key.
Source code in src/codex_django/notifications/adapters/cache_adapter.py
24 25 26 27 | |
set(key, value, timeout)
Store a cached content value with a TTL.
Source code in src/codex_django/notifications/adapters/cache_adapter.py
29 30 31 32 | |
Functions
Direct adapter
codex_django.notifications.adapters.direct_adapter
DjangoDirectAdapter
Inline (no-worker) notification delivery via Django's send_mail().
Useful for: - Development environments without Redis/ARQ - Simple use cases where async delivery is not required - Fallback when the queue is unavailable
Supports both payload modes: - Mode 1 (template): requires a TemplateRenderer from codex_platform. Renders Jinja2 identically to the production worker — dev == prod. - Mode 2 (rendered): sends html_content directly without rendering.
Usage::
# Mode 2 only (no renderer needed):
adapter = DjangoDirectAdapter()
# Mode 1 + Mode 2:
from codex_platform.notifications.renderer import TemplateRenderer
renderer = TemplateRenderer(templates_dir="path/to/templates")
adapter = DjangoDirectAdapter(renderer=renderer)
# Works the same as DjangoQueueAdapter:
adapter.enqueue("send_notification_task", payload=data)
Classes
DjangoDirectAdapter
Deliver notifications inline via Django send_mail().
Notes
The adapter implements the same enqueue interface as the queue-based adapter, which makes it useful for development, testing, and fallback delivery paths.
Source code in src/codex_django/notifications/adapters/direct_adapter.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
Functions
enqueue(task_name, payload)
Synchronously deliver or schedule delivery of a notification payload.
Source code in src/codex_django/notifications/adapters/direct_adapter.py
55 56 57 58 59 60 61 62 | |
aenqueue(task_name, payload)
async
Asynchronously deliver a notification payload in a worker thread.
Source code in src/codex_django/notifications/adapters/direct_adapter.py
64 65 66 67 68 69 | |
i18n adapter
codex_django.notifications.adapters.i18n_adapter
DjangoI18nAdapter
Provides language override context manager for notification content lookup.
Usage::
adapter = DjangoI18nAdapter()
with adapter.translation_override("de"):
subject = EmailContent.objects.get(key="booking_subject").text
Classes
DjangoI18nAdapter
Wraps Django's translation.override() for notification language switching.
Source code in src/codex_django/notifications/adapters/i18n_adapter.py
18 19 20 21 22 23 24 | |
Queue adapter
codex_django.notifications.adapters.queue_adapter
DjangoQueueAdapter
NotificationAdapter implementation that enqueues tasks via DjangoArqClient.
Wraps enqueue() in transaction.on_commit() by default so the ARQ job is only dispatched after the DB transaction commits successfully.
Usage::
adapter = DjangoQueueAdapter(arq_client=DjangoArqClient())
# From a sync view (WSGI):
adapter.enqueue("send_notification_task", payload=data)
# From an async view (ASGI):
await adapter.aenqueue("send_notification_task", payload=data)
Classes
DjangoQueueAdapter
Queue-backed notification adapter for ARQ-based delivery.
Source code in src/codex_django/notifications/adapters/queue_adapter.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
Functions
enqueue(task_name, payload)
Synchronously enqueue a notification payload.
Returns None when use_on_commit=True because the job is not
enqueued until the transaction commits. Otherwise returns the ARQ job id.
Source code in src/codex_django/notifications/adapters/queue_adapter.py
35 36 37 38 39 40 41 42 43 44 45 46 | |
aenqueue(task_name, payload)
async
Asynchronously enqueue a notification payload without on_commit.
Source code in src/codex_django/notifications/adapters/queue_adapter.py
48 49 50 | |
ARQ client adapter
codex_django.notifications.adapters.arq_client
Django-facing ARQ adapter built on top of codex-platform delivery primitives.
Classes
DjangoArqClient
Thin Django-friendly wrapper around codex-platform's ARQ adapter.
Source code in src/codex_django/notifications/adapters/arq_client.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
Functions
build_redis_settings_from_django()
staticmethod
Build ARQ RedisSettings from Django settings as a convenience fallback.
Source code in src/codex_django/notifications/adapters/arq_client.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
enqueue(task_name, payload)
Enqueue a task synchronously via the platform ARQ adapter.
Source code in src/codex_django/notifications/adapters/arq_client.py
71 72 73 74 | |
aenqueue(task_name, payload)
async
Enqueue a task asynchronously via the platform ARQ adapter.
Source code in src/codex_django/notifications/adapters/arq_client.py
76 77 78 79 | |