summaryrefslogtreecommitdiffstats
path: root/pyload/database/AccountDatabase.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/database/AccountDatabase.py')
-rw-r--r--pyload/database/AccountDatabase.py30
1 files changed, 17 insertions, 13 deletions
diff --git a/pyload/database/AccountDatabase.py b/pyload/database/AccountDatabase.py
index eaa1a3203..3ca841fbc 100644
--- a/pyload/database/AccountDatabase.py
+++ b/pyload/database/AccountDatabase.py
@@ -1,25 +1,29 @@
# -*- coding: utf-8 -*-
-from pyload.database import queue, async
-from pyload.database import DatabaseBackend
+from pyload.Api import AccountInfo
+from pyload.database import DatabaseMethods, queue, async
-class AccountMethods:
+class AccountMethods(DatabaseMethods):
@queue
- def loadAccounts(db):
- db.c.execute('SELECT plugin, loginname, activated, password, options FROM accounts;')
- return db.c.fetchall()
+ def loadAccounts(self):
+ self.c.execute('SELECT plugin, loginname, owner, activated, shared, password, options FROM accounts')
+
+ return [(AccountInfo(r[0], r[1], r[2], activated=r[3] is 1, shared=r[4] is 1), r[5], r[6]) for r in self.c]
@async
- def saveAccounts(db, data):
- # TODO: owner, shared
+ def saveAccounts(self, data):
- db.c.executemany(
- 'INSERT INTO accounts(plugin, loginname, activated, password, options) VALUES(?,?,?,?,?)', data)
+ self.c.executemany(
+ 'INSERT INTO accounts(plugin, loginname, owner, activated, shared, password, options) VALUES(?,?,?,?,?,?,?)',
+ data)
@async
- def removeAccount(db, plugin, loginname):
- db.c.execute('DELETE FROM accounts WHERE plugin=? AND loginname=?', (plugin, loginname))
+ def removeAccount(self, plugin, loginname):
+ self.c.execute('DELETE FROM accounts WHERE plugin=? AND loginname=?', (plugin, loginname))
+ @queue
+ def purgeAccounts(self):
+ self.c.execute('DELETE FROM accounts')
-DatabaseBackend.registerSub(AccountMethods) \ No newline at end of file
+AccountMethods.register() \ No newline at end of file