Changeset 1451 for pykota/trunk/pykota/storages
- Timestamp:
- 05/06/04 14:37:47 (20 years ago)
- Location:
- pykota/trunk/pykota/storages
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/ldapstorage.py
r1393 r1451 22 22 # 23 23 # $Log$ 24 # Revision 1.63 2004/05/06 12:37:46 jalet 25 # pkpgcounter : comments 26 # pkprinters : when --add is used, existing printers are now skipped. 27 # 24 28 # Revision 1.62 2004/03/05 14:31:58 jalet 25 29 # Improvement on strange history entries … … 444 448 """Extracts user information given its name.""" 445 449 user = StorageUser(self, username) 446 result = self.doSearch("(&(objectClass=pykotaAccount)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["userrdn"], username), ["pykota LimitBy", self.info["usermail"]], base=self.info["userbase"])450 result = self.doSearch("(&(objectClass=pykotaAccount)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["userrdn"], username), ["pykotaUserName", "pykotaLimitBy", self.info["usermail"]], base=self.info["userbase"]) 447 451 if result : 448 452 fields = result[0][1] 449 453 user.ident = result[0][0] 454 user.Name = fields.get("pykotaUserName", [username])[0] 450 455 user.Email = fields.get(self.info["usermail"]) 451 456 if user.Email is not None : … … 478 483 """Extracts group information given its name.""" 479 484 group = StorageGroup(self, groupname) 480 result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(%s=%s)))" % (groupname, self.info["grouprdn"], groupname), ["pykota LimitBy"], base=self.info["groupbase"])485 result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(%s=%s)))" % (groupname, self.info["grouprdn"], groupname), ["pykotaGroupName", "pykotaLimitBy"], base=self.info["groupbase"]) 481 486 if result : 482 487 fields = result[0][1] 483 488 group.ident = result[0][0] 489 group.Name = fields.get("pykotaGroupName", [groupname])[0] 484 490 group.LimitBy = fields.get("pykotaLimitBy") 485 491 if group.LimitBy is not None : … … 495 501 496 502 def getPrinterFromBackend(self, printername) : 497 """Extracts printer information given its name ."""503 """Extracts printer information given its name : returns first matching printer.""" 498 504 printer = StoragePrinter(self, printername) 499 result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" % (printername, self.info["printerrdn"], printername), ["pykotaPri cePerPage", "pykotaPricePerJob", "uniqueMember"], base=self.info["printerbase"])500 if result : 501 fields = result[0][1] 505 result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" % (printername, self.info["printerrdn"], printername), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember"], base=self.info["printerbase"]) 506 if result : 507 fields = result[0][1] # take only first matching printer, ignore the rest 502 508 printer.ident = result[0][0] 509 printer.Name = fields.get("pykotaPrinterName", [printername])[0] 503 510 printer.PricePerJob = float(fields.get("pykotaPricePerJob", [0.0])[0] or 0.0) 504 511 printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) -
pykota/trunk/pykota/storages/sql.py
r1358 r1451 22 22 # 23 23 # $Log$ 24 # Revision 1.38 2004/05/06 12:37:47 jalet 25 # pkpgcounter : comments 26 # pkprinters : when --add is used, existing printers are now skipped. 27 # 24 28 # Revision 1.37 2004/02/23 22:53:21 jalet 25 29 # Don't retrieve data when it's not needed, to avoid database queries … … 63 67 fields = result[0] 64 68 user.ident = fields.get("id") 69 user.Name = fields.get("username", username) 65 70 user.LimitBy = fields.get("limitby") 66 71 user.AccountBalance = fields.get("balance") … … 77 82 fields = result[0] 78 83 group.ident = fields.get("id") 84 group.Name = fields.get("groupname", groupname) 79 85 group.LimitBy = fields.get("limitby") 80 86 result = self.doSearch("SELECT SUM(balance) AS balance, SUM(lifetimepaid) AS lifetimepaid FROM users WHERE id IN (SELECT userid FROM groupsmembers WHERE groupid=%s)" % self.doQuote(group.ident)) … … 93 99 fields = result[0] 94 100 printer.ident = fields.get("id") 101 printer.Name = fields.get("printername", printername) 95 102 printer.PricePerJob = fields.get("priceperjob") 96 103 printer.PricePerPage = fields.get("priceperpage")