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