diff --git a/packetserver/runners/http_user_manager.py b/packetserver/runners/http_user_manager.py index b073ba7..680a034 100644 --- a/packetserver/runners/http_user_manager.py +++ b/packetserver/runners/http_user_manager.py @@ -28,21 +28,18 @@ 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]: - 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 - storage = ZODB.FileStorage.FileStorage(db_arg) - return ZODB.DB(storage) + 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)) # modern ZEO + return ZODB.DB(storage) + + # Local + storage = ZODB.FileStorage.FileStorage(db_arg) + return ZODB.DB(storage) def get_or_create_http_users(root): @@ -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")