Changeset 791 for pykota/trunk/pykota/storages/sql.py
- Timestamp:
- 02/10/03 13:07:31 (21 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/sql.py
r784 r791 15 15 # 16 16 # $Log$ 17 # Revision 1.18 2003/02/10 12:07:31 jalet 18 # Now repykota should output the recorded total page number for each printer too. 19 # 17 20 # Revision 1.17 2003/02/10 08:41:36 jalet 18 21 # edpykota's --reset command line option resets the limit date too. … … 77 80 class SQLStorage : 78 81 def getMatchingPrinters(self, printerpattern) : 79 """Returns the list of all printer names which match a certain pattern."""82 """Returns the list of all printers tuples (name, pagecounter) which match a certain pattern for the printer name.""" 80 83 printerslist = [] 81 84 # We 'could' do a SELECT printername FROM printers WHERE printername LIKE ... 82 85 # but we don't because other storages semantics may be different, so every 83 86 # storage should use fnmatch to match patterns and be storage agnostic 84 result = self.doQuery("SELECT printername FROM printers;")87 result = self.doQuery("SELECT printername, pagecounter FROM printers;") 85 88 result = self.doParseResult(result) 86 89 if result is not None : 87 90 for printer in result : 88 91 if fnmatch.fnmatchcase(printer["printername"], printerpattern) : 89 printerslist.append( printer["printername"])92 printerslist.append((printer["printername"], printer["pagecounter"])) 90 93 return printerslist 91 94 … … 96 99 def getPrinterUsers(self, printername) : 97 100 """Returns the list of usernames which uses a given printer.""" 98 result = self.doQuery("SELECT DISTINCT username FROM users WHERE id IN (SELECT userid FROM userpquota WHERE printerid IN (SELECT printerid FROM printers WHERE printername=%s)) ;" % self.doQuote(printername))101 result = self.doQuery("SELECT DISTINCT username FROM users WHERE id IN (SELECT userid FROM userpquota WHERE printerid IN (SELECT printerid FROM printers WHERE printername=%s)) ORDER BY username;" % self.doQuote(printername)) 99 102 result = self.doParseResult(result) 100 103 if result is None :