Index: /pykota/trunk/pykota/storages/sql.py
===================================================================
--- /pykota/trunk/pykota/storages/sql.py (revision 2707)
+++ /pykota/trunk/pykota/storages/sql.py (revision 2717)
@@ -729,5 +729,5 @@
         
     def deleteUser(self, user) :    
-        """Completely deletes an user from the Quota Storage."""
+        """Completely deletes an user from the database."""
         # TODO : What should we do if we delete the last person who used a given printer ?
         # TODO : we can't reassign the last job to the previous one, because next user would be
@@ -741,7 +741,22 @@
                   ] :
             self.doModify(q)
+            
+    def deleteUserPQuota(self, upquota) :    
+        """Completely deletes an user print quota entry from the database."""
+        for q in [ 
+                    "DELETE FROM jobhistory WHERE userid=%s" % self.doQuote(upquota.User.ident),
+                    "DELETE FROM userpquota WHERE userid=%s" % self.doQuote(upquota.ident),
+                  ] :
+            self.doModify(q)
+        
+    def deleteGroupPQuota(self, gpquota) :    
+        """Completely deletes a group print quota entry from the database."""
+        for q in [ 
+                    "DELETE FROM grouppquota WHERE groupid=%s" % self.doQuote(gpquota.ident),
+                  ] :
+            self.doModify(q)
         
     def deleteGroup(self, group) :    
-        """Completely deletes a group from the Quota Storage."""
+        """Completely deletes a group from the database."""
         for q in [
                    "DELETE FROM groupsmembers WHERE groupid=%s" % self.doQuote(group.ident),
@@ -752,5 +767,5 @@
             
     def deletePrinter(self, printer) :    
-        """Completely deletes a printer from the Quota Storage."""
+        """Completely deletes a printer from the database."""
         for q in [ 
                     "DELETE FROM printergroupsmembers WHERE groupid=%s OR printerid=%s" % (self.doQuote(printer.ident), self.doQuote(printer.ident)),
@@ -763,5 +778,5 @@
             
     def deleteBillingCode(self, code) :    
-        """Completely deletes a billing code from the Quota Storage."""
+        """Completely deletes a billing code from the database."""
         for q in [
                    "DELETE FROM billingcodes WHERE id=%s" % self.doQuote(code.ident),
Index: /pykota/trunk/pykota/storages/ldapstorage.py
===================================================================
--- /pykota/trunk/pykota/storages/ldapstorage.py (revision 2707)
+++ /pykota/trunk/pykota/storages/ldapstorage.py (revision 2717)
@@ -1405,4 +1405,19 @@
                 self.doDelete(group.ident)
                 
+    def deleteUserPQuota(self, upquota) :    
+        """Completely deletes an user print quota entry from the database."""
+        uname = self.userCharsetToDatabase(upquota.User.Name)
+        pname = self.userCharsetToDatabase(upquota.Printer.Name)
+        result = self.doSearch("(&(objectClass=pykotaJob)(pykotaUserName=%s)(pykotaPrinterName=%s))" \
+                                   % (uname, pname), \
+                                   base=self.info["jobbase"])
+        for (ident, fields) in result :
+            self.doDelete(ident)
+        self.doDelete(upquota.ident)
+        
+    def deleteGroupPQuota(self, gpquota) :    
+        """Completely deletes a group print quota entry from the database."""
+        self.doDelete(gpquota.ident)
+                
     def deletePrinter(self, printer) :    
         """Completely deletes a printer from the Quota Storage."""
Index: /pykota/trunk/pykota/storage.py
===================================================================
--- /pykota/trunk/pykota/storage.py (revision 2707)
+++ /pykota/trunk/pykota/storage.py (revision 2717)
@@ -26,5 +26,5 @@
 
 class PyKotaStorageError(Exception):
-    """An exception for Quota Storage related stuff."""
+    """An exception for database related stuff."""
     def __init__(self, message = ""):
         self.message = message
@@ -35,5 +35,5 @@
         
 class StorageObject :
-    """Object present in the Quota Storage."""
+    """Object present in the database."""
     def __init__(self, parent) :
         "Initialize minimal data."""
@@ -98,5 +98,5 @@
         
     def delete(self) :    
-        """Deletes an user from the Quota Storage."""
+        """Deletes an user from the database."""
         self.parent.beginTransaction()
         try :
@@ -142,5 +142,5 @@
         
     def delete(self) :    
-        """Deletes a group from the Quota Storage."""
+        """Deletes a group from the database."""
         self.parent.beginTransaction()
         try :
@@ -216,5 +216,5 @@
         
     def delete(self) :    
-        """Deletes a printer from the Quota Storage."""
+        """Deletes a printer from the database."""
         self.parent.beginTransaction()
         try :
@@ -343,4 +343,20 @@
         return jobprice
         
+    def delete(self) :    
+        """Deletes an user print quota entry from the database."""
+        self.parent.beginTransaction()
+        try :
+            self.parent.deleteUserPQuota(self)
+        except PyKotaStorageError, msg :    
+            self.parent.rollbackTransaction()
+            raise PyKotaStorageError, msg
+        else :    
+            self.parent.commitTransaction()
+            if self.parent.usecache :
+                for (k, v) in self.parent.caches["USERPQUOTAS"].items() :
+                    if v.User.Name == self.User.Name :
+                        self.parent.flushEntry("USERPQUOTAS", "%s@%s" % (v.User.Name, v.Printer.Name))
+            self.Exists = 0
+        
 class StorageGroupPQuota(StorageObject) :
     """Group Print Quota class."""
@@ -413,4 +429,20 @@
         self.HardLimit = hardlimit
         self.DateLimit = None
+        
+    def delete(self) :    
+        """Deletes a group print quota entry from the database."""
+        self.parent.beginTransaction()
+        try :
+            self.parent.deleteGroupPQuota(self)
+        except PyKotaStorageError, msg :    
+            self.parent.rollbackTransaction()
+            raise PyKotaStorageError, msg
+        else :    
+            self.parent.commitTransaction()
+            if self.parent.usecache :
+                for (k, v) in self.parent.caches["GROUPPQUOTAS"].items() :
+                    if v.Group.Name == self.Group.Name :
+                        self.parent.flushEntry("GROUPPQUOTAS", "%s@%s" % (v.Group.Name, v.Printer.Name))
+            self.Exists = 0
         
 class StorageJob(StorageObject) :
@@ -773,5 +805,5 @@
         
 def openConnection(pykotatool) :
-    """Returns a connection handle to the appropriate Quota Storage Database."""
+    """Returns a connection handle to the appropriate database."""
     backendinfo = pykotatool.config.getStorageBackend()
     backend = backendinfo["storagebackend"]
