summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-12 22:10:06 -0700
committerAndrew Godwin2022-11-12 22:10:06 -0700
commit143a4a6e8c70557710d1b207a176f169d145ed1e (patch)
tree133454aa4da2b5614a33bc4a91d7b152f50eb40c /core
parent878f56b411279cd9865a7ec05f1d14c9f70f6187 (diff)
downloadtakahe-143a4a6e8c70557710d1b207a176f169d145ed1e.tar.gz
takahe-143a4a6e8c70557710d1b207a176f169d145ed1e.tar.bz2
takahe-143a4a6e8c70557710d1b207a176f169d145ed1e.zip
Start some settings work
Diffstat (limited to 'core')
-rw-r--r--core/config.py21
-rw-r--r--core/context.py4
2 files changed, 21 insertions, 4 deletions
diff --git a/core/config.py b/core/config.py
index 0f09404..b9f6878 100644
--- a/core/config.py
+++ b/core/config.py
@@ -1,3 +1,20 @@
-class Config:
+import pydantic
- pass
+
+class Config(pydantic.BaseModel):
+
+ # Basic configuration options
+ site_name: str = "takahē"
+ identity_max_age: int = 24 * 60 * 60
+
+ # Cached ORM object storage
+ __singleton__ = None
+
+ class Config:
+ env_prefix = "takahe_"
+
+ @classmethod
+ def load(cls) -> "Config":
+ if cls.__singleton__ is None:
+ cls.__singleton__ = cls()
+ return cls.__singleton__
diff --git a/core/context.py b/core/context.py
index 026ac11..17617b9 100644
--- a/core/context.py
+++ b/core/context.py
@@ -1,7 +1,7 @@
-from django.conf import settings
+from core.config import Config
def config_context(request):
return {
- "config": {"site_name": settings.SITE_NAME},
+ "config": Config.load(),
}