Changeset 1692 for pykota/trunk/pykota/storages/ldapstorage.py
- Timestamp:
- 09/02/04 12:09:30 (20 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/ldapstorage.py
r1601 r1692 22 22 # 23 23 # $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 # 24 28 # Revision 1.73 2004/07/17 20:37:27 jalet 25 29 # Missing file... Am I really stupid ? … … 633 637 lastjob.lastjobident = result[0][0] 634 638 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. 636 644 if result : 637 645 fields = result[0][1] … … 1145 1153 def deleteUser(self, user) : 1146 1154 """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 = [] 1153 1156 result = self.doSearch("(&(objectClass=pykotaJob)(pykotaUserName=%s))" % user.Name, base=self.info["jobbase"]) 1154 1157 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 : 1155 1173 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 1159 1175 result = self.doSearch("objectClass=pykotaAccount", None, base=user.ident, scope=ldap.SCOPE_BASE) 1160 1176 if result :