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", version="0.1.0",
) )
# Mount static files # New static (relative to this file's location always works)
app.mount("/static", StaticFiles(directory="packetserver/http/static"), name="static") from pathlib import Path
# Templates BASE_DIR = Path(__file__).parent.resolve()
templates = Jinja2Templates(directory="packetserver/http/templates")
app.mount("/static", StaticFiles(directory=BASE_DIR / "static"), name="static")
templates = Jinja2Templates(directory=BASE_DIR / "templates")
security = HTTPBasic() security = HTTPBasic()

View File

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