Changeset 1244

Show
Ignore:
Timestamp:
12/29/03 15:12:48 (20 years ago)
Author:
uid67467
Message:

Tries to workaround possible integrity violations when retrieving printer groups

Location:
pykota/trunk/pykota/storages
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storages/ldapstorage.py

    r1240 r1244  
    2222# 
    2323# $Log$ 
     24# Revision 1.42  2003/12/29 14:12:48  uid67467 
     25# Tries to workaround possible integrity violations when retrieving printer groups 
     26# 
    2427# Revision 1.41  2003/12/27 16:49:25  uid67467 
    2528# Should be ok now. 
     
    567570        if result : 
    568571            for (printerid, fields) in result : 
    569                 parentprinter = self.getPrinter(fields.get("pykotaPrinterName")[0]) 
    570                 if parentprinter.Exists : 
    571                     pgroups.append(parentprinter) 
     572                if printerid != printer.ident : # In case of integrity violation. 
     573                    parentprinter = self.getPrinter(fields.get("pykotaPrinterName")[0]) 
     574                    if parentprinter.Exists : 
     575                        pgroups.append(parentprinter) 
    572576        return pgroups 
    573577         
  • pykota/trunk/pykota/storages/pgstorage.py

    r1240 r1244  
    2222# 
    2323# $Log$ 
     24# Revision 1.26  2003/12/29 14:12:48  uid67467 
     25# Tries to workaround possible integrity violations when retrieving printer groups 
     26# 
    2427# Revision 1.25  2003/12/27 16:49:25  uid67467 
    2528# Should be ok now. 
     
    398401        """Get all the printer groups this printer is a member of.""" 
    399402        pgroups = [] 
    400         result = self.doSearch("SELECT printername FROM printergroupsmembers JOIN printers ON groupid=id WHERE printerid=%s;" % self.doQuote(printer.ident)) 
     403        result = self.doSearch("SELECT groupid,printername FROM printergroupsmembers JOIN printers ON groupid=id WHERE printerid=%s;" % self.doQuote(printer.ident)) 
    401404        if result : 
    402405            for record in result : 
    403                 parentprinter = self.getPrinter(record.get("printername")) 
    404                 if parentprinter.Exists : 
    405                     pgroups.append(parentprinter) 
     406                if record["groupid"] != printer.ident : # in case of integrity violation 
     407                    parentprinter = self.getPrinter(record.get("printername")) 
     408                    if parentprinter.Exists : 
     409                        pgroups.append(parentprinter) 
    406410        return pgroups 
    407411