Index: pykota/trunk/pykota/tool.py
===================================================================
--- pykota/trunk/pykota/tool.py (revision 1565)
+++ pykota/trunk/pykota/tool.py (revision 1582)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.109  2004/07/01 17:45:49  jalet
+# Added code to handle the description field for printers
+#
 # Revision 1.108  2004/06/24 23:09:30  jalet
 # Also prints read size on last block
@@ -475,4 +478,9 @@
         if self.debug :
             self.logger.log_message(message, "debug")
+            
+    def printError(self, message) :        
+        """Sends a message to standard error."""
+        sys.stderr.write("%s\n" % message)
+        sys.stderr.flush()
         
     def clean(self) :    
Index: pykota/trunk/pykota/storages/sql.py
===================================================================
--- pykota/trunk/pykota/storages/sql.py (revision 1531)
+++ pykota/trunk/pykota/storages/sql.py (revision 1582)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.43  2004/07/01 17:45:49  jalet
+# Added code to handle the description field for printers
+#
 # Revision 1.42  2004/06/08 17:44:43  jalet
 # Payment now gets deleted when the user is deleted
@@ -115,6 +118,7 @@
             printer.ident = fields.get("id")
             printer.Name = fields.get("printername", printername)
-            printer.PricePerJob = fields.get("priceperjob")
-            printer.PricePerPage = fields.get("priceperpage")
+            printer.PricePerJob = fields.get("priceperjob") or 0.0
+            printer.PricePerPage = fields.get("priceperpage") or 0.0
+            printer.Description = fields.get("description") or ""
             printer.Exists = 1
         return printer    
@@ -228,6 +232,7 @@
                     printer = StoragePrinter(self, record["printername"])
                     printer.ident = record.get("id")
-                    printer.PricePerJob = record.get("priceperjob")
-                    printer.PricePerPage = record.get("priceperpage")
+                    printer.PricePerJob = record.get("priceperjob") or 0.0
+                    printer.PricePerPage = record.get("priceperpage") or 0.0
+                    printer.Description = record.get("description") or ""
                     printer.Exists = 1
                     printers.append(printer)
@@ -313,4 +318,8 @@
         self.doModify("UPDATE printers SET priceperpage=%s, priceperjob=%s WHERE id=%s" % (self.doQuote(printer.PricePerPage), self.doQuote(printer.PricePerJob), self.doQuote(printer.ident)))
         
+    def writePrinterDescription(self, printer) :    
+        """Write the printer's description back into the storage."""
+        self.doModify("UPDATE printers SET description=%s WHERE id=%s" % (self.doQuote(printer.Description), self.doQuote(printer.ident)))
+        
     def writeUserLimitBy(self, user, limitby) :    
         """Sets the user's limiting factor."""
Index: pykota/trunk/pykota/storages/ldapstorage.py
===================================================================
--- pykota/trunk/pykota/storages/ldapstorage.py (revision 1534)
+++ pykota/trunk/pykota/storages/ldapstorage.py (revision 1582)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.71  2004/07/01 17:45:49  jalet
+# Added code to handle the description field for printers
+#
 # Revision 1.70  2004/06/10 20:50:25  jalet
 # Better log message
@@ -535,5 +538,5 @@
         """Extracts printer information given its name : returns first matching printer."""
         printer = StoragePrinter(self, printername)
-        result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" % (printername, self.info["printerrdn"], printername), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember"], base=self.info["printerbase"])
+        result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" % (printername, self.info["printerrdn"], printername), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember", "description"], base=self.info["printerbase"])
         if result :
             fields = result[0][1]       # take only first matching printer, ignore the rest
@@ -543,4 +546,5 @@
             printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0)
             printer.uniqueMember = fields.get("uniqueMember", [])
+            printer.Description = fields.get("description", [""])[0]
             printer.Exists = 1
         return printer    
@@ -700,5 +704,5 @@
         printers = []
         # see comment at the same place in pgstorage.py
-        result = self.doSearch("(&(objectClass=pykotaPrinter)(|%s))" % "".join(["(pykotaPrinterName=%s)(%s=%s)" % (pname, self.info["printerrdn"], pname) for pname in printerpattern.split(",")]), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember"], base=self.info["printerbase"])
+        result = self.doSearch("(&(objectClass=pykotaPrinter)(|%s))" % "".join(["(pykotaPrinterName=%s)(%s=%s)" % (pname, self.info["printerrdn"], pname) for pname in printerpattern.split(",")]), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember", "description"], base=self.info["printerbase"])
         if result :
             for (printerid, fields) in result :
@@ -709,4 +713,5 @@
                 printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0)
                 printer.uniqueMember = fields.get("uniqueMember", [])
+                printer.Description = fields.get("description", [""])[0]
                 printer.Exists = 1
                 printers.append(printer)
@@ -895,4 +900,11 @@
                    "pykotaPricePerPage" : str(printer.PricePerPage),
                    "pykotaPricePerJob" : str(printer.PricePerJob),
+                 }
+        self.doModify(printer.ident, fields)
+        
+    def writePrinterDescription(self, printer) :    
+        """Write the printer's description back into the storage."""
+        fields = {
+                   "description" : str(printer.Description),
                  }
         self.doModify(printer.ident, fields)
Index: pykota/trunk/pykota/reporter.py
===================================================================
--- pykota/trunk/pykota/reporter.py (revision 1418)
+++ pykota/trunk/pykota/reporter.py (revision 1582)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.9  2004/07/01 17:45:49  jalet
+# Added code to handle the description field for printers
+#
 # Revision 1.8  2004/03/24 15:15:24  jalet
 # Began integration of Henrik Janhagen's work on quota-then-balance
@@ -70,5 +73,5 @@
         
     def getPrinterTitle(self, printer) :     
-        return _("Report for %s quota on printer %s") % ((self.isgroup and "group") or "user", printer.Name)
+        return (_("Report for %s quota on printer %s") % ((self.isgroup and "group") or "user", printer.Name)) + (" (%s)" % printer.Description)
         
     def getPrinterGraceDelay(self, printer) :    
@@ -100,5 +103,5 @@
         balance = float(entry.AccountBalance or 0.0)
         lifetimepaid = float(entry.LifeTimePaid or 0.0)
-	
+        
         #balance
         if entry.LimitBy and (entry.LimitBy.lower() == "balance") :    
Index: pykota/trunk/pykota/storage.py
===================================================================
--- pykota/trunk/pykota/storage.py (revision 1523)
+++ pykota/trunk/pykota/storage.py (revision 1582)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.56  2004/07/01 17:45:49  jalet
+# Added code to handle the description field for printers
+#
 # Revision 1.55  2004/06/05 22:18:04  jalet
 # Now catches some exceptions earlier.
@@ -317,4 +320,5 @@
         self.PricePerPage = None
         self.PricePerJob = None
+        self.Description = None
         
     def __getattr__(self, name) :    
@@ -353,4 +357,12 @@
             self.PricePerJob = float(priceperjob)
         self.parent.writePrinterPrices(self)
+        
+    def setDescription(self, description = None) :    
+        """Sets the printer's prices."""
+        if description is None :
+            description = self.Description
+        else :    
+            self.Description = str(description)
+        self.parent.writePrinterDescription(self)
         
     def delete(self) :    
