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.
|
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]:
|
if ":" in db_arg:
|
||||||
logging.debug("using ZEO storage")
|
parts = db_arg.split(":")
|
||||||
import ZEO
|
if len(parts) == 2 and parts[1].isdigit():
|
||||||
host, port_str = db_arg.split(":")
|
import ZEO
|
||||||
port = int(port_str)
|
host = parts[0]
|
||||||
storage = ZEO.client_storage((host, port))
|
port = int(parts[1])
|
||||||
return ZODB.DB(storage) # return the DB
|
storage = ZEO.client((host, port)) # correct modern ZEO client function
|
||||||
else:
|
return ZODB.DB(storage)
|
||||||
logging.debug("using standard storage")
|
|
||||||
storage = ZODB.FileStorage.FileStorage(db_arg)
|
# Local FileStorage fallback
|
||||||
return ZODB.DB(storage) # return the DB
|
storage = ZODB.FileStorage.FileStorage(db_arg)
|
||||||
|
return ZODB.DB(storage)
|
||||||
|
|
||||||
|
|
||||||
def get_db_connection():
|
def get_db_connection():
|
||||||
|
|||||||
Reference in New Issue
Block a user