Changeset 1520 for pykota/trunk/pykota/storages
- Timestamp:
- 06/04/04 01:14:11 (20 years ago)
- Location:
- pykota/trunk/pykota/storages
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/ldapstorage.py
r1510 r1520 22 22 # 23 23 # $Log$ 24 # Revision 1.67 2004/06/03 23:14:10 jalet 25 # Now stores the job's size in bytes in the database. 26 # Preliminary work on payments storage : database schemas are OK now, 27 # but no code to store payments yet. 28 # Removed schema picture, not relevant anymore. 29 # 24 30 # Revision 1.66 2004/05/28 20:56:45 jalet 25 31 # Extended syntax for LDAP specific newuser and newgroup directives. Untested. … … 603 609 lastjob.lastjobident = result[0][0] 604 610 lastjobident = result[0][1]["pykotaLastJobIdent"][0] 605 result = self.doSearch("objectClass=pykotaJob", ["pykota HostName", "pykotaUserName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaJobSize", "pykotaAction", "pykotaJobPrice", "pykotaFileName", "pykotaTitle", "pykotaCopies", "pykotaOptions", "createTimestamp"], base="cn=%s,%s" % (lastjobident, self.info["jobbase"]), scope=ldap.SCOPE_BASE)611 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) 606 612 if result : 607 613 fields = result[0][1] … … 618 624 lastjob.JobOptions = fields.get("pykotaOptions", [""])[0] 619 625 lastjob.JobHostName = fields.get("pykotaHostName", [""])[0] 626 lastjob.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0] 620 627 date = fields.get("createTimestamp", ["19700101000000"])[0] 621 628 year = int(date[:4]) … … 945 952 self.doModify(lastjob.ident, fields) 946 953 947 def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None ) :954 def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None, jobsizebytes=None) : 948 955 """Adds a job in a printer's history.""" 949 956 if (not self.disablehistory) or (not printer.LastJob.Exists) : … … 966 973 "pykotaOptions" : str(options), 967 974 "pykotaHostName" : str(clienthost), 975 "pykotaJobSizeBytes" : str(jobsizebytes), 968 976 } 969 977 if (not self.disablehistory) or (not printer.LastJob.Exists) : … … 1046 1054 where = precond 1047 1055 jobs = [] 1048 result = self.doSearch(where, fields=["pykota HostName", "pykotaUserName", "pykotaPrinterName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaAction", "pykotaJobSize", "pykotaJobPrice", "pykotaFileName", "pykotaTitle", "pykotaCopies", "pykotaOptions", "createTimestamp"], base=self.info["jobbase"])1056 result = self.doSearch(where, fields=["pykotaJobSizeBytes", "pykotaHostName", "pykotaUserName", "pykotaPrinterName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaAction", "pykotaJobSize", "pykotaJobPrice", "pykotaFileName", "pykotaTitle", "pykotaCopies", "pykotaOptions", "createTimestamp"], base=self.info["jobbase"]) 1049 1057 if result : 1050 1058 for (ident, fields) in result : … … 1061 1069 job.JobOptions = fields.get("pykotaOptions", [""])[0] 1062 1070 job.JobHostName = fields.get("pykotaHostName", [""])[0] 1071 job.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0] 1063 1072 date = fields.get("createTimestamp", ["19700101000000"])[0] 1064 1073 year = int(date[:4]) -
pykota/trunk/pykota/storages/pgstorage.py
r1327 r1520 22 22 # 23 23 # $Log$ 24 # Revision 1.36 2004/06/03 23:14:11 jalet 25 # Now stores the job's size in bytes in the database. 26 # Preliminary work on payments storage : database schemas are OK now, 27 # but no code to store payments yet. 28 # Removed schema picture, not relevant anymore. 29 # 24 30 # Revision 1.35 2004/02/02 22:44:16 jalet 25 31 # Preliminary work on Relationnal Database Independance via DB-API 2.0 … … 223 229 elif type(field) == type(0) : 224 230 typ = "int" 231 elif type(field) == type(0L) : 232 typ = "int" 225 233 else : 226 234 typ = "text" -
pykota/trunk/pykota/storages/sql.py
r1502 r1520 22 22 # 23 23 # $Log$ 24 # Revision 1.40 2004/06/03 23:14:11 jalet 25 # Now stores the job's size in bytes in the database. 26 # Preliminary work on payments storage : database schemas are OK now, 27 # but no code to store payments yet. 28 # Removed schema picture, not relevant anymore. 29 # 24 30 # Revision 1.39 2004/05/26 14:50:12 jalet 25 31 # First try at saving the job-originating-hostname in the database … … 162 168 lastjob.JobDate = fields.get("jobdate") 163 169 lastjob.JobHostName = fields.get("hostname") 170 lastjob.JobSizeBytes = fields.get("jobsizebytes") 164 171 lastjob.Exists = 1 165 172 return lastjob … … 339 346 self.doModify("UPDATE jobhistory SET jobsize=%s, jobprice=%s WHERE id=%s" % (self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(lastjob.ident))) 340 347 341 def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None ) :348 def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None, jobsizebytes=None) : 342 349 """Adds a job in a printer's history.""" 343 350 if (not self.disablehistory) or (not printer.LastJob.Exists) : 344 351 if jobsize is not None : 345 self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options, hostname ) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(clienthost)))352 self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options, hostname, jobsizebytes) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(clienthost), self.doQuote(jobsizebytes))) 346 353 else : 347 self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, filename, title, copies, options, hostname ) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(clienthost)))354 self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, filename, title, copies, options, hostname, jobsizebytes) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(clienthost), self.doQuote(jobsizebytes))) 348 355 else : 349 356 # here we explicitly want to reset jobsize to NULL if needed 350 self.doModify("UPDATE jobhistory SET userid=%s, jobid=%s, pagecounter=%s, action=%s, jobsize=%s, jobprice=%s, filename=%s, title=%s, copies=%s, options=%s, hostname=%s, job date=now() WHERE id=%s" % (self.doQuote(user.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(clienthost), self.doQuote(printer.LastJob.ident)))357 self.doModify("UPDATE jobhistory SET userid=%s, jobid=%s, pagecounter=%s, action=%s, jobsize=%s, jobprice=%s, filename=%s, title=%s, copies=%s, options=%s, hostname=%s, jobsizebytes=%s, jobdate=now() WHERE id=%s" % (self.doQuote(user.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(clienthost), self.doQuote(jobsizebytes), self.doQuote(printer.LastJob.ident))) 351 358 352 359 def writeUserPQuotaLimits(self, userpquota, softlimit, hardlimit) : … … 406 413 job.JobDate = fields.get("jobdate") 407 414 job.JobHostName = fields.get("hostname") 415 job.JobSizeBytes = fields.get("jobsizebytes") 408 416 job.UserName = fields.get("username") 409 417 job.PrinterName = fields.get("printername")