Fixed database logic.

This commit is contained in:
Michael Woods
2025-12-21 23:08:53 -05:00
parent f960baaf37
commit 9803e2acf4

View File

@@ -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")
if ":" in db_arg:
parts = db_arg.split(":")
if len(parts) == 2 and parts[1].isdigit():
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")
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) # return the DB
return ZODB.DB(storage)
def get_db_connection():