Changeset 700
- Timestamp:
- 02/05/03 23:28:38 (22 years ago)
- Location:
- pykota/trunk/pykota/storages
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/postgresql.py
r695 r700 15 15 # 16 16 # $Log$ 17 # Revision 1.2 2003/02/05 22:28:38 jalet 18 # More robust storage 19 # 17 20 # Revision 1.1 2003/02/05 21:28:17 jalet 18 21 # Initial import into CVS … … 58 61 59 62 def doParseResult(self, result) : 60 """Returns the result as a Python dictionnary.""" 61 try : 62 return result.dictresult()[0] 63 except IndexError : 64 return None # not found 63 """Returns the result as a list of Python mappings.""" 64 if result.ntuples() > 0 : 65 return result.dictresult() 65 66 -
pykota/trunk/pykota/storages/sql.py
r695 r700 15 15 # 16 16 # $Log$ 17 # Revision 1.2 2003/02/05 22:28:38 jalet 18 # More robust storage 19 # 17 20 # Revision 1.1 2003/02/05 21:28:17 jalet 18 21 # Initial import into CVS … … 26 29 def getUserId(self, username) : 27 30 result = self.doQuery("SELECT id FROM users WHERE username=%s;" % self.doQuote(username)) 28 return self.doParseResult(result)["id"] 31 try : 32 return self.doParseResult(result)[0]["id"] 33 except TypeError : # Not found 34 return 29 35 30 36 def getPrinterId(self, printername) : 31 37 result = self.doQuery("SELECT id FROM printers WHERE printername=%s;" % self.doQuote(printername)) 32 return self.doParseResult(result)["id"] 38 try : 39 return self.doParseResult(result)[0]["id"] 40 except TypeError : # Not found 41 return 33 42 34 43 def getPrinterPageCounter(self, printername) : 35 44 result = self.doQuery("SELECT pagecounter, lastusername FROM printers WHERE printername=%s;" % self.doQuote(printername)) 36 return self.doParseResult(result) 45 try : 46 return self.doParseResult(result)[0] 47 except TypeError : # Not found 48 return 37 49 38 50 def updatePrinterPageCounter(self, printername, username, pagecount) : … … 53 65 def getUserPQuota(self, username, printername) : 54 66 result = self.doQuery("SELECT pagecounter, softlimit, hardlimit, datelimit FROM userpquota WHERE userid=%s AND printerid=%s;" % (self.doQuote(self.getUserId(username)), self.doQuote(self.getPrinterId(printername)))) 55 return self.doParseResult(result) 67 try : 68 return self.doParseResult(result)[0] 69 except TypeError : # Not found 70 return 56 71 57 72 def setUserPQuota(self, username, printername, softlimit, hardlimit) :