DB works now.
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user