Changeset 1032
- Timestamp:
- 06/16/03 23:55:15 (21 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/ldapstorage.py
r1031 r1032 21 21 # 22 22 # $Log$ 23 # Revision 1.10 2003/06/16 21:55:15 jalet 24 # More work on LDAP, again. Problem detected. 25 # 23 26 # Revision 1.9 2003/06/16 11:59:09 jalet 24 27 # More work on LDAP … … 242 245 if result : 243 246 return [v[self.info["grouprdn"]][0] for (k, v) in result] 247 return [] 244 248 245 249 def addPrinter(self, printername) : … … 353 357 if result : 354 358 groupname = result[0][1]["pykotaGroupName"][0] 355 members = self.getGroupMembersNames(groupname) 359 members = self.getGroupMembersNames(groupname) or [] 356 360 balance = lifetimepaid = 0.0 357 361 for member in members : … … 417 421 "pykotaSoftLimit" : str(softlimit), 418 422 "pykotaHardLimit" : str(hardlimit), 423 "pykotaDateLimit" : "None", 419 424 } 420 425 return self.doModify(userquotaid, fields) … … 425 430 "pykotaSoftLimit" : str(softlimit), 426 431 "pykotaHardLimit" : str(hardlimit), 432 "pykotaDateLimit" : "None", 427 433 } 428 434 return self.doModify(groupquotaid, fields) … … 486 492 "datelimit" : datelimit 487 493 } 488 members = self.getGroupMembersNames(groupname) 494 members = self.getGroupMembersNames(groupname) or [] 489 495 pagecounter = lifepagecounter = 0 490 496 printerusers = self.getPrinterUsers(printerid) … … 513 519 return self.doModify(groupquotaid, fields) 514 520 515 def addJobToHistory(self, jobid, userid, printerid, pagecounter, action ) :521 def addJobToHistory(self, jobid, userid, printerid, pagecounter, action, jobsize=None) : 516 522 """Adds a job to the history: (jobid, userid, printerid, last page counter taken from requester).""" 517 raise PyKotaStorageError, "Not implemented !" 523 uuid = self.genUUID() 524 printername = self.getPrinterName(printerid) 525 fields = { 526 "objectClass" : ["pykotaObject", "pykotaJob"], 527 "cn" : uuid, 528 "pykotaUserName" : self.getUserName(userid), 529 "pykotaPrinterName" : printername, 530 "pykotaJobId" : jobid, 531 "pykotaPrinterPageCounter" : str(pagecounter), 532 "pykotaAction" : action, 533 } 534 if jobsize is not None : 535 fields.update({ "pykotaJobSize" : str(jobsize) }) 536 dn = "cn=%s,%s" % (uuid, self.info["jobbase"]) 537 self.doAdd(dn, fields) 538 result = self.doSearch("(&(objectClass=pykotaLastJob)(pykotaPrinterName=%s))" % printername, None, base=self.info["lastjobbase"]) 539 if result : 540 lastjdn = result[0][0] 541 fields = { 542 "pykotaLastJobIdent" : uuid, 543 } 544 self.doModify(lastjdn, fields) 545 else : 546 lastjuuid = self.genUUID() 547 lastjdn = "cn=%s,%s" % (lasjuuid, self.info["lastjobbase"]) 548 fields = { 549 "objectClass" : ["pykotaObject", "pykotaLastJob"], 550 "cn" : lastjuuid, 551 "pykotaPrinterName" : printername, 552 "pykotaLastJobIdent" : uuid, 553 } 554 self.doAdd(lastjdn, fields) 518 555 519 556 def updateJobSizeInHistory(self, historyid, jobsize) : 520 557 """Updates a job size in the history given the history line's id.""" 521 raise PyKotaStorageError, "Not implemented !" 558 result = self.doSearch("(&(objectClass=pykotaJob)(cn=%s))" % historyid, ["cn"], base=self.info["jobbase"]) 559 if result : 560 fields = { 561 "pykotaJobSize" : str(jobsize), 562 } 563 self.doModify(result[0][0], fields) 522 564 523 565 def getPrinterPageCounter(self, printerid) : … … 538 580 "username" : fields.get("pykotaUserName")[0], 539 581 "pagecounter" : int(fields.get("pykotaPrinterPageCounter")[0]), 582 "jobsize" : int(fields.get("pykotaJobSize")[0]), 540 583 } 541 584