Changeset 1692

Show
Ignore:
Timestamp:
09/02/04 12:09:30 (20 years ago)
Author:
jalet
Message:

Fixed bug in LDAP user deletion code which didn't correctly delete the user's
pykotaLastJob entries.

Location:
pykota/trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/NEWS

    r1687 r1692  
    2222PyKota NEWS : 
    2323 
     24    - 1.20alpha6 : 
     25       
     26        - Fixed a bug in LDAP user deletion code. 
     27         
    2428    - 1.20alpha5 : 
    2529       
  • pykota/trunk/pykota/reporter.py

    r1582 r1692  
    2222# 
    2323# $Log$ 
     24# Revision 1.10  2004/09/02 10:09:30  jalet 
     25# Fixed bug in LDAP user deletion code which didn't correctly delete the user's 
     26# pykotaLastJob entries. 
     27# 
    2428# Revision 1.9  2004/07/01 17:45:49  jalet 
    2529# Added code to handle the description field for printers 
     
    8892             
    8993    def getPrinterRealPageCounter(self, printer) :         
    90         try : 
    91             msg = "%9i" % printer.LastJob.PrinterPageCounter 
    92         except TypeError :      
    93             msg = _("unknown") 
     94        msg = _("unknown") 
     95        if printer.LastJob.Exists : 
     96            try : 
     97                msg = "%9i" % printer.LastJob.PrinterPageCounter 
     98            except TypeError :      
     99                pass 
    94100        return _("Real : %s") % msg 
    95101                 
  • pykota/trunk/pykota/storage.py

    r1624 r1692  
    2222# 
    2323# $Log$ 
     24# Revision 1.58  2004/09/02 10:09:30  jalet 
     25# Fixed bug in LDAP user deletion code which didn't correctly delete the user's 
     26# pykotaLastJob entries. 
     27# 
    2428# Revision 1.57  2004/07/22 22:41:48  jalet 
    2529# Hardware accounting for LPRng should be OK now. UNTESTED. 
     
    480484         
    481485class StorageJob(StorageObject) : 
    482     """Printer's Last Job class.""" 
     486    """Printer's Job class.""" 
    483487    def __init__(self, parent) : 
    484488        StorageObject.__init__(self, parent) 
  • pykota/trunk/pykota/storages/ldapstorage.py

    r1601 r1692  
    2222# 
    2323# $Log$ 
     24# Revision 1.74  2004/09/02 10:09:30  jalet 
     25# Fixed bug in LDAP user deletion code which didn't correctly delete the user's 
     26# pykotaLastJob entries. 
     27# 
    2428# Revision 1.73  2004/07/17 20:37:27  jalet 
    2529# Missing file... Am I really stupid ? 
     
    633637            lastjob.lastjobident = result[0][0] 
    634638            lastjobident = result[0][1]["pykotaLastJobIdent"][0] 
    635             result = self.doSearch("objectClass=pykotaJob", ["pykotaJobSizeBytes", "pykotaHostName", "pykotaUserName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaJobSize", "pykotaAction", "pykotaJobPrice", "pykotaFileName", "pykotaTitle", "pykotaCopies", "pykotaOptions", "createTimestamp"], base="cn=%s,%s" % (lastjobident, self.info["jobbase"]), scope=ldap.SCOPE_BASE) 
     639            result = None 
     640            try : 
     641                result = self.doSearch("objectClass=pykotaJob", ["pykotaJobSizeBytes", "pykotaHostName", "pykotaUserName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaJobSize", "pykotaAction", "pykotaJobPrice", "pykotaFileName", "pykotaTitle", "pykotaCopies", "pykotaOptions", "createTimestamp"], base="cn=%s,%s" % (lastjobident, self.info["jobbase"]), scope=ldap.SCOPE_BASE) 
     642            except PyKotaStorageError :     
     643                pass # Last job entry exists, but job probably doesn't exist anymore.  
    636644            if result : 
    637645                fields = result[0][1] 
     
    11451153    def deleteUser(self, user) :     
    11461154        """Completely deletes an user from the Quota Storage.""" 
    1147         # TODO : What should we do if we delete the last person who used a given printer ? 
    1148         # TODO : we can't reassign the last job to the previous one, because next user would be 
    1149         # TODO : incorrectly charged (overcharged). 
    1150         result = self.doSearch("(&(objectClass=pykotaLastJob)(pykotaUserName=%s))" % user.Name, base=self.info["lastjobbase"]) 
    1151         for (ident, fields) in result : 
    1152             self.doDelete(ident) 
     1155        todelete = []     
    11531156        result = self.doSearch("(&(objectClass=pykotaJob)(pykotaUserName=%s))" % user.Name, base=self.info["jobbase"]) 
    11541157        for (ident, fields) in result : 
     1158            todelete.append(ident) 
     1159             
     1160        result = self.doSearch("(&(objectClass=pykotaUserPQuota)(pykotaUserName=%s))" % user.Name, ["pykotaPrinterName", "pykotaUserName"], base=self.info["userquotabase"]) 
     1161        for (ident, fields) in result : 
     1162            # ensure the user print quota entry will be deleted 
     1163            todelete.append(ident) 
     1164             
     1165            # if last job of current printer was printed by the user 
     1166            # to delete, we also need to delete the printer's last job entry. 
     1167            printername = fields["pykotaPrinterName"][0] 
     1168            printer = self.getPrinter(printername) 
     1169            if printer.LastJob.UserName == user.Name : 
     1170                todelete.append(printer.LastJob.lastjobident) 
     1171             
     1172        for ident in todelete :     
    11551173            self.doDelete(ident) 
    1156         result = self.doSearch("(&(objectClass=pykotaUserPQuota)(pykotaUserName=%s))" % user.Name, ["pykotaUserName"], base=self.info["userquotabase"]) 
    1157         for (ident, fields) in result : 
    1158             self.doDelete(ident) 
     1174             
    11591175        result = self.doSearch("objectClass=pykotaAccount", None, base=user.ident, scope=ldap.SCOPE_BASE)     
    11601176        if result : 
  • pykota/trunk/pykota/version.py

    r1687 r1692  
    2222# 
    2323 
    24 __version__ = "1.20alpha5_unofficial" 
     24__version__ = "1.20alpha6_unofficial" 
    2525 
    2626__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""