From 9ea1ab90b4705ef4d5ce37ded36a214f276c0a18 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 31 Mar 2013 18:32:13 +0200 Subject: add and delete accounts, db will be resetted --- module/AccountManager.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'module/AccountManager.py') diff --git a/module/AccountManager.py b/module/AccountManager.py index d90c957c3..6e2786d55 100644 --- a/module/AccountManager.py +++ b/module/AccountManager.py @@ -22,6 +22,7 @@ from random import choice from module.common.json_layer import json from module.utils import lock + class AccountManager: """manages all accounts""" @@ -45,7 +46,6 @@ class AccountManager: self.createAccount(plugin, loginname, password, options) - return def iterAccounts(self): """ yields login, account for all accounts""" @@ -55,11 +55,14 @@ class AccountManager: def saveAccounts(self): """save all account information""" + # TODO: multi user + # TODO: activated data = [] for name, plugin in self.accounts.iteritems(): - data.extend([(name, acc.loginname, acc.activated, acc.password, json.dumps(acc.options)) for acc in - plugin.itervalues()]) + data.extend( + [(name, acc.loginname, 1 if acc.activated else 0, acc.password, json.dumps(acc.options)) for acc in + plugin.itervalues()]) self.core.db.saveAccounts(data) def createAccount(self, plugin, loginname, password, options): @@ -102,7 +105,7 @@ class AccountManager: self.core.db.removeAccount(plugin, user) self.core.eventManager.dispatchEvent("account:deleted", plugin, user) else: - self.core.log.debug("Remove non existing account %s %s" % (plugin, user)) + self.core.log.debug("Remove non existent account %s %s" % (plugin, user)) @lock -- cgit v1.2.3