Changeset 2768 for pykota/trunk/pykota/storages/sql.py
- Timestamp:
- 03/01/06 10:47:49 (18 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/sql.py
r2765 r2768 527 527 return groupsandquotas 528 528 529 def addPrinter(self, printername) : 530 """Adds a printer to the quota storage, returns it.""" 531 self.doModify("INSERT INTO printers (printername) VALUES (%s)" % self.doQuote(self.userCharsetToDatabase(printername))) 532 return self.getPrinter(printername) 529 def addPrinter(self, printer) : 530 """Adds a printer to the quota storage, returns the old value if it already exists.""" 531 try : 532 self.doModify("INSERT INTO printers (printername, passthrough, maxjobsize, description, priceperpage, priceperjob) VALUES (%s, %s, %s, %s, %s, %s)" \ 533 % (self.doQuote(self.userCharsetToDatabase(printer.Name)), \ 534 self.doQuote((printer.PassThrough and "t") or "f"), \ 535 self.doQuote(printer.MaxJobSize or 0), \ 536 self.doQuote(self.userCharsetToDatabase(printer.Description)), \ 537 self.doQuote(printer.PricePerPage or 0.0), \ 538 self.doQuote(printer.PricePerJob or 0.0))) 539 except PyKotaStorageError : 540 # TODO : check if this is an error different from a duplicate insert 541 # return the existing entry which has to be modified 542 return self.getPrinter(printer.Name) 543 else : 544 printer.isDirty = False 545 return None # the entry created doesn't need further modification 533 546 534 547 def addBillingCode(self, bcode) : … … 626 639 self.doModify("UPDATE printers SET passthrough=%s, maxjobsize=%s, description=%s, priceperpage=%s, priceperjob=%s WHERE id=%s" \ 627 640 % (self.doQuote((printer.PassThrough and "t") or "f"), \ 628 self.doQuote(printer.MaxJobSize ), \641 self.doQuote(printer.MaxJobSize or 0), \ 629 642 self.doQuote(self.userCharsetToDatabase(printer.Description)), \ 630 self.doQuote(printer.PricePerPage ), \631 self.doQuote(printer.PricePerJob ), \643 self.doQuote(printer.PricePerPage or 0.0), \ 644 self.doQuote(printer.PricePerJob or 0.0), \ 632 645 self.doQuote(printer.ident))) 633 646 … … 852 865 printerids = ", ".join(["%s" % self.doQuote(p.ident) for p in printers]) 853 866 self.deleteInTransaction([ 854 "DELETE FROM printergroupsmembers WHERE groupid IN (%s) OR printerid IN (%s)" % printerids,867 "DELETE FROM printergroupsmembers WHERE groupid IN (%s) OR printerid IN (%s)" % (printerids, printerids), 855 868 "DELETE FROM jobhistory WHERE printerid IN (%s)" % printerids, 856 869 "DELETE FROM grouppquota WHERE printerid IN (%s)" % printerids,