Changeset 2763
- Timestamp:
- 02/28/06 00:14:02 (19 years ago)
- Location:
- pykota/trunk/pykota/storages
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/ldapstorage.py
r2756 r2763 1462 1462 self.doDelete(group.ident) 1463 1463 1464 def deleteManyBillingCodesFromNames(self, billingcodes) : 1465 """Deletes many billing codes from their names.""" 1466 for bcode in self.getMatchingBillingCodes(",".join(billingcodes)) : 1467 bcode.delete() 1468 1469 def deleteManyUsersFromNames(self, usernames) : 1470 """Deletes many users from their names.""" 1471 for user in self.getMatchingUsers(",".join(usernames)) : 1472 user.delete() 1473 1474 def deleteManyGroupsFromNames(self, groupnames) : 1475 """Deletes many groups from their names.""" 1476 for group in self.getMatchingGroups(",".join(groupnames)) : 1477 group.delete() 1478 1479 def deleteManyPrintersFromNames(self, printernames) : 1480 """Deletes many printers from their names.""" 1481 for printer in self.getMatchingPrinters(",".join(printernames)) : 1482 printer.delete() 1483 1464 1484 def deleteManyUserPQuotas(self, printers, users) : 1465 1485 """Deletes many user print quota entries.""" -
pykota/trunk/pykota/storages/sql.py
r2758 r2763 801 801 self.doModify(q) 802 802 803 def deleteInTransaction(self, queries) : 804 """Does many deletions in a single transaction.""" 805 self.beginTransaction() 806 try : 807 for q in queries : 808 self.doModify(q) 809 except : 810 self.rollbackTransaction() 811 raise 812 else : 813 self.commitTransaction() 814 815 def deleteManyBillingCodesFromNames(self, billingcodes) : 816 """Deletes many billing codes from their names.""" 817 codelabels = ", ".join(["%s" % self.doQuote(b) for b in billingcodes]) 818 self.deleteInTransaction([ 819 "DELETE FROM billingcodes WHERE billingcode IN (%s)" % codelabels,]) 820 821 def deleteManyUsersFromNames(self, usernames) : 822 """Deletes many users from their names.""" 823 usernames = ", ".join(["%s" % self.doQuote(u) for u in usernames]) 824 self.deleteInTransaction([ 825 "DELETE FROM payments WHERE userid IN (SELECT id FROM users WHERE username IN %s)" % usernames, 826 "DELETE FROM groupsmembers WHERE userid IN (SELECT id FROM users WHERE username IN %s)" % usernames, 827 "DELETE FROM jobhistory WHERE userid IN (SELECT id FROM users WHERE username IN %s)" % usernames, 828 "DELETE FROM userpquota WHERE userid IN (SELECT id FROM users WHERE username IN %s)" % usernames, 829 "DELETE FROM users WHERE username IN %s" % usernames,]) 830 831 def deleteManyPrintersFromNames(self, printernames) : 832 """Deletes many printers from their names.""" 833 printernames = ", ".join(["%s" % self.doQuote(p) for p in printernames]) 834 self.deleteInTransaction([ 835 "DELETE FROM printergroupsmembers WHERE groupid=%s OR printerid=%s" % (self.doQuote(printer.ident), self.doQuote(printer.ident)), 836 "DELETE FROM jobhistory WHERE printerid=%s" % self.doQuote(printer.ident), 837 "DELETE FROM grouppquota WHERE printerid=%s" % self.doQuote(printer.ident), 838 "DELETE FROM userpquota WHERE printerid=%s" % self.doQuote(printer.ident), 839 "DELETE FROM printers WHERE id=%s" % self.doQuote(printer.ident),]) 840 803 841 def deleteManyUserPQuotas(self, printers, users) : 804 842 """Deletes many user print quota entries.""" 805 843 printerids = ", ".join(["%s" % self.doQuote(p.ident) for p in printers]) 806 844 userids = ", ".join(["%s" % self.doQuote(u.ident) for u in users]) 807 for q in[845 self.deleteInTransaction([ 808 846 "DELETE FROM jobhistory WHERE userid IN (%s) AND printerid IN (%s)" \ 809 847 % (userids, printerids), 810 848 "DELETE FROM userpquota WHERE userid IN (%s) AND printerid IN (%s)" \ 811 % (userids, printerids), 812 ] : 813 self.doModify(q) 849 % (userids, printerids),]) 814 850 815 851 def deleteManyGroupPQuotas(self, printers, groups) : … … 817 853 printerids = ", ".join(["%s" % self.doQuote(p.ident) for p in printers]) 818 854 groupids = ", ".join(["%s" % self.doQuote(g.ident) for g in groups]) 819 for q in[855 self.deleteInTransaction([ 820 856 "DELETE FROM grouppquota WHERE groupid IN (%s) AND printerid IN (%s)" \ 821 % (groupids, printerids), 822 ] : 823 self.doModify(q) 857 % (groupids, printerids),]) 824 858 825 859 def deleteUserPQuota(self, upquota) :