From 9803e2acf4c9c50291920d4f9df518e10711e3b2 Mon Sep 17 00:00:00 2001 From: Michael Woods Date: Sun, 21 Dec 2025 23:08:53 -0500 Subject: [PATCH] Fixed database logic. --- packetserver/runners/http_server.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/packetserver/runners/http_server.py b/packetserver/runners/http_server.py index 398c5a6..1c7badc 100644 --- a/packetserver/runners/http_server.py +++ b/packetserver/runners/http_server.py @@ -27,17 +27,18 @@ def open_database(db_arg: str) -> ZODB.DB: """ Open a ZODB database from either a local FileStorage path or ZEO address. """ - 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(":") - port = int(port_str) - storage = ZEO.client_storage((host, port)) - return ZODB.DB(storage) # return the DB - else: - logging.debug("using standard storage") - storage = ZODB.FileStorage.FileStorage(db_arg) - return ZODB.DB(storage) # return the DB + if ":" in db_arg: + parts = db_arg.split(":") + if len(parts) == 2 and parts[1].isdigit(): + import ZEO + host = parts[0] + port = int(parts[1]) + storage = ZEO.client((host, port)) # correct modern ZEO client function + return ZODB.DB(storage) + + # Local FileStorage fallback + storage = ZODB.FileStorage.FileStorage(db_arg) + return ZODB.DB(storage) def get_db_connection():