Changeset 1259

Show
Ignore:
Timestamp:
01/08/04 17:33:27 (21 years ago)
Author:
jalet
Message:

Additionnal check to not create a circular printers group.

Location:
pykota/trunk/pykota
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storage.py

    r1258 r1259  
    2222# 
    2323# $Log$ 
     24# Revision 1.35  2004/01/08 16:33:27  jalet 
     25# Additionnal check to not create a circular printers group. 
     26# 
    2427# Revision 1.34  2004/01/08 16:24:49  jalet 
    2528# edpykota now supports adding printers to printer groups. 
     
    245248    def addPrinterToGroup(self, printer) :     
    246249        """Adds a printer to a printer group.""" 
    247         if printer not in self.parent.getParentPrinters(self) : 
     250        if (printer not in self.parent.getParentPrinters(self)) and (printer.ident != self.ident) : 
    248251            self.parent.writePrinterToGroup(self, printer) 
    249252         
  • pykota/trunk/pykota/storages/ldapstorage.py

    r1258 r1259  
    2222# 
    2323# $Log$ 
     24# Revision 1.46  2004/01/08 16:33:27  jalet 
     25# Additionnal check to not create a circular printers group. 
     26# 
    2427# Revision 1.45  2004/01/08 16:24:49  jalet 
    2528# edpykota now supports adding printers to printer groups. 
     
    821824    def writePrinterToGroup(self, pgroup, printer) : 
    822825        """Puts a printer into a printer group.""" 
    823         if (printer.ident not in pgroup.uniqueMember) and (printer.ident != pgroup.ident) : 
     826        if printer.ident not in pgroup.uniqueMember : 
    824827            fields = { 
    825828                       "uniqueMember" : pgroup.uniqueMember + [printer.ident] 
  • pykota/trunk/pykota/storages/pgstorage.py

    r1258 r1259  
    2222# 
    2323# $Log$ 
     24# Revision 1.30  2004/01/08 16:33:27  jalet 
     25# Additionnal check to not create a circular printers group. 
     26# 
    2427# Revision 1.29  2004/01/08 16:24:49  jalet 
    2528# edpykota now supports adding printers to printer groups. 
     
    510513    def writePrinterToGroup(self, pgroup, printer) : 
    511514        """Puts a printer into a printer group.""" 
    512         self.doModify("INSERT INTO printergroupsmembers (groupid, printerid) VALUES (%s, %s);" % (self.doQuote(pgroup.ident), self.doQuote(printer.ident))) 
     515        children = [] 
     516        result = self.doSearch("SELECT printerid FROM printergroupsmembers WHERE groupid=%s;" % self.doQuote(pgroup.ident)) 
     517        if result : 
     518            for record in result : 
     519                children.append(record.get("printerid")) # TODO : put this into the database integrity rules 
     520        if printer.ident not in children :         
     521            self.doModify("INSERT INTO printergroupsmembers (groupid, printerid) VALUES (%s, %s);" % (self.doQuote(pgroup.ident), self.doQuote(printer.ident))) 
    513522         
    514523    def deleteUser(self, user) :