DB works now.

This commit is contained in:
Michael Woods
2025-12-20 22:14:06 -05:00
parent 1f27712cdf
commit ae52188bcc
2 changed files with 8 additions and 6 deletions

View File

@@ -21,11 +21,13 @@ app = FastAPI(
version="0.1.0",
)
# Mount static files
app.mount("/static", StaticFiles(directory="packetserver/http/static"), name="static")
# New static (relative to this file's location always works)
from pathlib import Path
# Templates
templates = Jinja2Templates(directory="packetserver/http/templates")
BASE_DIR = Path(__file__).parent.resolve()
app.mount("/static", StaticFiles(directory=BASE_DIR / "static"), name="static")
templates = Jinja2Templates(directory=BASE_DIR / "templates")
security = HTTPBasic()

View File

@@ -22,7 +22,7 @@ _db = None
_connection = None
def open_database(db_arg: str) -> ZODB.DB.DB:
def open_database(db_arg: str) -> ZODB.DB:
"""
Open a ZODB database from either a local FileStorage path or ZEO address.
Reuses the same logic as http_user_manager.py.
@@ -45,7 +45,7 @@ def open_database(db_arg: str) -> ZODB.DB.DB:
def get_db_connection():
"""Helper used in http/server.py dependency (get_current_http_user)"""
global _connection
if _connection is None or _connection.closed:
if _connection is None or getattr(_connection, "opened", None) is None:
if _db is None:
raise RuntimeError("Database not opened run the runner properly")
_connection = _db.open()