Changeset 2107
- Timestamp:
- 02/25/05 15:47:27 (20 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/ldapstorage.py
r2106 r2107 22 22 # 23 23 # $Log$ 24 # Revision 1.103 2005/02/25 14:47:27 jalet 25 # Improved robustness for manually modified LDAP trees 26 # 24 27 # Revision 1.102 2005/02/25 14:31:07 jalet 25 28 # Improved robustness … … 619 622 raise PyKotaStorageError, message 620 623 624 def filterNames(self, records, attribute) : 625 """Returns a list of 'attribute' from a list of records. 626 627 Logs any missing attribute. 628 """ 629 result = [] 630 for record in records : 631 attrval = record[1].get(attribute, [None])[0] 632 if attrval is None : 633 self.tool.printInfo("Object %s has no %s attribute !" % (record[0], attribute), "error") 634 else : 635 result.append(attrval) 636 return result 637 621 638 def getAllPrintersNames(self, printername=None) : 622 639 """Extracts all printer names or only the printers' names matching the optional parameter.""" … … 627 644 result = self.doSearch(ldapfilter, ["pykotaPrinterName"], base=self.info["printerbase"]) 628 645 if result : 629 printernames = [record[1]["pykotaPrinterName"][0] for record in result]646 printernames = self.filterNames(result, "pykotaPrinterName") 630 647 return printernames 631 648 … … 638 655 result = self.doSearch(ldapfilter, ["pykotaUserName"], base=self.info["userbase"]) 639 656 if result : 640 usernames = filter(None, [record[1].get("pykotaUserName", [None])[0] for record in result])657 usernames = self.filterNames(result, "pykotaUserName") 641 658 return usernames 642 659 … … 649 666 result = self.doSearch(ldapfilter, ["pykotaGroupName"], base=self.info["groupbase"]) 650 667 if result : 651 groupnames = [record[1]["pykotaGroupName"][0] for record in result]668 groupnames = self.filterNames(result, "pykotaGroupName") 652 669 return groupnames 653 670