Updated manager function db.
This commit is contained in:
@@ -28,19 +28,16 @@ HTTP_USERS_KEY = "httpUsers"
|
||||
|
||||
|
||||
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]:
|
||||
if ":" in db_arg:
|
||||
parts = db_arg.split(":")
|
||||
if len(parts) == 2 and parts[1].isdigit():
|
||||
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}")
|
||||
return ZEO.DB((host,port))
|
||||
else:
|
||||
# Local FileStorage path
|
||||
host = parts[0]
|
||||
port = int(parts[1])
|
||||
storage = ZEO.client((host, port)) # modern ZEO
|
||||
return ZODB.DB(storage)
|
||||
|
||||
# Local
|
||||
storage = ZODB.FileStorage.FileStorage(db_arg)
|
||||
return ZODB.DB(storage)
|
||||
|
||||
@@ -133,8 +130,7 @@ def main():
|
||||
|
||||
main_users = root.setdefault('users', PersistentMapping())
|
||||
if callsign not in main_users:
|
||||
new_user = User(callsign)
|
||||
new_user.write_new(root)
|
||||
User.write_new(main_users, args.callsign) # correct: pass mapping + callsign
|
||||
print(f" → Also created regular BBS user {callsign} (with UUID)")
|
||||
else:
|
||||
print(f" → Regular BBS user {callsign} already exists")
|
||||
|
||||
Reference in New Issue
Block a user