From f960baaf374269305c1e82070f5a133a2ea57a19 Mon Sep 17 00:00:00 2001 From: Michael Woods Date: Sun, 21 Dec 2025 23:04:48 -0500 Subject: [PATCH] Added changes to database server logic. --- packetserver/runners/http_server.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packetserver/runners/http_server.py b/packetserver/runners/http_server.py index 22e63f4..398c5a6 100644 --- a/packetserver/runners/http_server.py +++ b/packetserver/runners/http_server.py @@ -15,6 +15,7 @@ import sys import uvicorn import ZODB.FileStorage import ZODB.DB +import logging from packetserver.http.server import app # Global DB and connection for reuse in the FastAPI dependency @@ -25,21 +26,18 @@ _connection = None 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. """ if ":" in db_arg and db_arg.count(":") == 1 and "." in db_arg.split(":")[0]: + logging.debug("using ZEO storage") import ZEO host, port_str = db_arg.split(":") - try: - port = int(port_str) - except ValueError: - raise ValueError(f"Invalid port in ZEO address: {db_arg}") - storage = ZEO.DB((host, port)) - return storage + port = int(port_str) + storage = ZEO.client_storage((host, port)) + return ZODB.DB(storage) # return the DB else: - # Local FileStorage path + logging.debug("using standard storage") storage = ZODB.FileStorage.FileStorage(db_arg) - return ZODB.DB(storage) + return ZODB.DB(storage) # return the DB def get_db_connection():