- Timestamp:
- 02/23/04 23:53:21 (21 years ago)
- Location:
- pykota/trunk
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/NEWS
r1356 r1358 22 22 PyKota NEWS : 23 23 24 - 1.18alpha8 : 25 26 - Don't retrieve data when not needed. 27 This avoids many database queries. 28 24 29 - 1.18alpha7 : 25 30 -
pykota/trunk/pykota/storage.py
r1333 r1358 22 22 # 23 23 # $Log$ 24 # Revision 1.42 2004/02/23 22:53:21 jalet 25 # Don't retrieve data when it's not needed, to avoid database queries 26 # 24 27 # Revision 1.41 2004/02/04 17:12:33 jalet 25 28 # Removing a printer from a printers group should work now. … … 257 260 self.PricePerPage = None 258 261 self.PricePerJob = None 259 self.LastJob = None 260 262 263 def __getattr__(self, name) : 264 """Delays data retrieval until it's really needed.""" 265 if name == "LastJob" : 266 self.LastJob = self.parent.getPrinterLastJob(self) 267 return self.LastJob 268 else : 269 raise AttributeError, name 270 261 271 def addJobToHistory(self, jobid, user, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None) : 262 272 """Adds a job to the printer's history.""" … … 309 319 self.HardLimit = None 310 320 self.DateLimit = None 311 self.ParentPrintersUserPQuota = (user.Exists and printer.Exists and parent.getParentPrintersUserPQuota(self)) or [] 321 322 def __getattr__(self, name) : 323 """Delays data retrieval until it's really needed.""" 324 if name == "ParentPrintersUserPQuota" : 325 self.ParentPrintersUserPQuota = (self.User.Exists and self.Printer.Exists and self.parent.getParentPrintersUserPQuota(self)) or [] 326 return self.ParentPrintersUserPQuota 327 else : 328 raise AttributeError, name 312 329 313 330 def setDateLimit(self, datelimit) : … … 383 400 def __init__(self, parent) : 384 401 StorageObject.__init__(self, parent) 385 self.User = None386 self.Printer = None402 self.UserName = None 403 self.PrinterName = None 387 404 self.JobId = None 388 405 self.PrinterPageCounter = None … … 396 413 self.JobOptions = None 397 414 415 def __getattr__(self, name) : 416 """Delays data retrieval until it's really needed.""" 417 if name == "User" : 418 self.User = self.parent.getUser(self.UserName) 419 return self.User 420 elif name == "Printer" : 421 self.Printer = self.parent.getPrinter(self.PrinterName) 422 return self.Printer 423 else : 424 raise AttributeError, name 425 398 426 class StorageLastJob(StorageJob) : 399 427 """Printer's Last Job class.""" … … 401 429 StorageJob.__init__(self, parent) 402 430 self.Printer = printer 431 self.UserName = None 432 433 def __getattr__(self, name) : 434 """Delays data retrieval until it's really needed.""" 435 if name == "User" : 436 self.User = self.parent.getUser(self.UserName) 437 return self.User 438 else : 439 raise AttributeError, name 403 440 404 441 def setSize(self, jobsize) : -
pykota/trunk/pykota/storages/ldapstorage.py
r1357 r1358 22 22 # 23 23 # $Log$ 24 # Revision 1.55 2004/02/23 22:53:21 jalet 25 # Don't retrieve data when it's not needed, to avoid database queries 26 # 24 27 # Revision 1.54 2004/02/20 16:38:39 jalet 25 28 # ldapcache directive marked as experimental … … 472 475 printer.PricePerJob = float(fields.get("pykotaPricePerJob")[0] or 0.0) 473 476 printer.PricePerPage = float(fields.get("pykotaPricePerPage")[0] or 0.0) 474 printer.LastJob = self.getPrinterLastJob(printer)475 477 printer.uniqueMember = fields.get("uniqueMember", []) 476 478 printer.Exists = 1 … … 557 559 lastjob.ident = result[0][0] 558 560 lastjob.JobId = fields.get("pykotaJobId")[0] 559 lastjob.User = self.getUser(fields.get("pykotaUserName")[0])561 lastjob.UserName = fields.get("pykotaUserName")[0] 560 562 lastjob.PrinterPageCounter = int(fields.get("pykotaPrinterPageCounter")[0] or 0) 561 563 lastjob.JobSize = int(fields.get("pykotaJobSize", [0])[0]) … … 636 638 printer.PricePerPage = float(fields.get("pykotaPricePerPage")[0] or 0.0) 637 639 printer.uniqueMember = fields.get("uniqueMember", []) 638 printer.LastJob = self.getPrinterLastJob(printer)639 640 printer.Exists = 1 640 641 printers.append(printer) … … 993 994 job.JobDate = "%04i-%02i-%02i %02i:%02i:%02i" % (year, month, day, hour, minute, second) 994 995 if (datelimit is None) or (job.JobDate <= datelimit) : 995 job.User = self.getUser(fields.get("pykotaUserName")[0])996 job.Printer = self.getPrinter(fields.get("pykotaPrinterName")[0])996 job.UserName = fields.get("pykotaUserName")[0] 997 job.PrinterName = fields.get("pykotaPrinterName")[0] 997 998 job.Exists = 1 998 999 jobs.append(job) -
pykota/trunk/pykota/storages/sql.py
r1332 r1358 22 22 # 23 23 # $Log$ 24 # Revision 1.37 2004/02/23 22:53:21 jalet 25 # Don't retrieve data when it's not needed, to avoid database queries 26 # 24 27 # Revision 1.36 2004/02/04 13:24:41 jalet 25 28 # pkprinters can now remove printers from printers groups. … … 92 95 printer.PricePerJob = fields.get("priceperjob") 93 96 printer.PricePerPage = fields.get("priceperpage") 94 printer.LastJob = self.getPrinterLastJob(printer)95 97 printer.Exists = 1 96 98 return printer … … 139 141 lastjob.ident = fields.get("id") 140 142 lastjob.JobId = fields.get("jobid") 141 lastjob.User = self.getUser(fields.get("username"))143 lastjob.UserName = fields.get("username") 142 144 lastjob.PrinterPageCounter = fields.get("pagecounter") 143 145 lastjob.JobSize = fields.get("jobsize") … … 204 206 printer.PricePerJob = record.get("priceperjob") 205 207 printer.PricePerPage = record.get("priceperpage") 206 printer.LastJob = self.getPrinterLastJob(printer)207 208 printer.Exists = 1 208 209 printers.append(printer) … … 391 392 job.JobOptions = fields.get("options") 392 393 job.JobDate = fields.get("jobdate") 393 job.User = self.getUser(fields.get("username"))394 job.Printer = self.getPrinter(fields.get("printername"))394 job.UserName = fields.get("username") 395 job.PrinterName = fields.get("printername") 395 396 job.Exists = 1 396 397 jobs.append(job) -
pykota/trunk/pykota/version.py
r1356 r1358 22 22 # 23 23 24 __version__ = "1.18alpha 7_unofficial"24 __version__ = "1.18alpha8_unofficial" 25 25 26 26 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""