Index: pykota/trunk/pykota/storages/sql.py
===================================================================
--- pykota/trunk/pykota/storages/sql.py (revision 1327)
+++ pykota/trunk/pykota/storages/sql.py (revision 1330)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.35  2004/02/04 11:17:00  jalet
+# pkprinters command line tool added.
+#
 # Revision 1.34  2004/02/02 22:44:16  jalet
 # Preliminary work on Relationnal Database Independance via DB-API 2.0
@@ -408,3 +411,14 @@
                  ] :  
             self.doModify(q)
-        
+            
+    def deletePrinter(self, printer) :    
+        """Completely deletes a printer from the Quota Storage."""
+        for q in [ 
+                    "DELETE FROM printergroupsmembers WHERE groupid=%s OR printerid=%s" % (self.doQuote(printer.ident), self.doQuote(printer.ident)),
+                    "DELETE FROM jobhistory WHERE printerid=%s" % self.doQuote(printer.ident),
+                    "DELETE FROM grouppquota WHERE printerid=%s" % self.doQuote(printer.ident),
+                    "DELETE FROM userpquota WHERE printerid=%s" % self.doQuote(printer.ident),
+                    "DELETE FROM printers WHERE id=%s" % self.doQuote(printer.ident),
+                  ] :
+            self.doModify(q)
+        
Index: pykota/trunk/pykota/storages/ldapstorage.py
===================================================================
--- pykota/trunk/pykota/storages/ldapstorage.py (revision 1320)
+++ pykota/trunk/pykota/storages/ldapstorage.py (revision 1330)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.50  2004/02/04 11:17:00  jalet
+# pkprinters command line tool added.
+#
 # Revision 1.49  2004/01/29 22:35:45  jalet
 # Small fix from Matt.
@@ -974,3 +977,24 @@
             else :    
                 self.doDelete(group.ident)
-            
+                
+    def deletePrinter(self, printer) :    
+        """Completely deletes an user from the Quota Storage."""
+        result = self.doSearch("(&(objectClass=pykotaLastJob)(pykotaPrinterName=%s))" % printer.Name, base=self.info["lastjobbase"])
+        for (ident, fields) in result :
+            self.doDelete(ident)
+        result = self.doSearch("(&(objectClass=pykotaJob)(pykotaPrinterName=%s))" % printer.Name, base=self.info["jobbase"])
+        for (ident, fields) in result :
+            self.doDelete(ident)
+        result = self.doSearch("(&(objectClass=pykotaGroupPQuota)(pykotaPrinterName=%s))" % printer.Name, base=self.info["groupquotabase"])
+        for (ident, fields) in result :
+            self.doDelete(ident)
+        result = self.doSearch("(&(objectClass=pykotaUserPQuota)(pykotaPrinterName=%s))" % printer.Name, base=self.info["userquotabase"])
+        for (ident, fields) in result :
+            self.doDelete(ident)
+        for parent in self.getParentPrinters(printer) :  
+            parent.uniqueMember.remove(printer.ident)
+            fields = {
+                       "uniqueMember" : parent.uniqueMember,
+                     }  
+            self.doModify(parent.ident, fields)         
+        self.doDelete(printer.ident)    
Index: pykota/trunk/pykota/storage.py
===================================================================
--- pykota/trunk/pykota/storage.py (revision 1285)
+++ pykota/trunk/pykota/storage.py (revision 1330)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.39  2004/02/04 11:16:59  jalet
+# pkprinters command line tool added.
+#
 # Revision 1.38  2004/01/12 22:43:40  jalet
 # New formula to compute a job's price
@@ -272,4 +275,15 @@
             self.PricePerJob = float(priceperjob)
         self.parent.writePrinterPrices(self)
+        
+    def delete(self) :    
+        """Deletes a printer from the Quota Storage."""
+        self.parent.beginTransaction()
+        try :
+            self.parent.deletePrinter(self)
+        except PyKotaStorageError, msg :    
+            self.parent.rollbackTransaction()
+            raise PyKotaStorageError, msg
+        else :    
+            self.parent.commitTransaction()
         
 class StorageUserPQuota(StorageObject) :
Index: pykota/trunk/pykota/version.py
===================================================================
--- pykota/trunk/pykota/version.py (revision 1325)
+++ pykota/trunk/pykota/version.py (revision 1330)
@@ -22,5 +22,5 @@
 #
 
-__version__ = "1.18alpha1_unofficial"
+__version__ = "1.18alpha2_unofficial"
 
 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""
