Fix independent loading of contextutil
authorMagnus Hagander <magnus@hagander.net>
Wed, 17 Sep 2025 11:38:30 +0000 (13:38 +0200)
committerMagnus Hagander <magnus@hagander.net>
Wed, 17 Sep 2025 11:38:30 +0000 (13:38 +0200)
Contextutil is loaded by jinjapdf, but didn't work without patching away
access to settings. Fix that, so it's back to working independently.

postgresqleu/confreg/contextutil.py

index 101e7cd4a7ccdc2a70ddd5feba133a234b34ed0b..c58a8fabbce2a9189c764c741b93db6be3edf02f 100644 (file)
@@ -3,8 +3,13 @@ import json
 import logging
 import copy
 
-from postgresqleu.util.context_processors import settings_context
-
+try:
+    from postgresqleu.util.context_processors import settings_context
+except ImportError:
+    # When running standalone jinjapdf, we will fail to import the global settings,
+    # so in this case just set it to empty.
+    def settings_context():
+        return {}
 
 try:
     import yaml