Show
Ignore:
Timestamp:
05/26/04 16:50:12 (20 years ago)
Author:
jalet
Message:

First try at saving the job-originating-hostname in the database

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storages/ldapstorage.py

    r1451 r1502  
    2222# 
    2323# $Log$ 
     24# Revision 1.64  2004/05/26 14:50:01  jalet 
     25# First try at saving the job-originating-hostname in the database 
     26# 
    2427# Revision 1.63  2004/05/06 12:37:46  jalet 
    2528# pkpgcounter : comments 
     
    591594            lastjob.lastjobident = result[0][0] 
    592595            lastjobident = result[0][1]["pykotaLastJobIdent"][0] 
    593             result = self.doSearch("objectClass=pykotaJob", ["pykotaUserName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaJobSize", "pykotaAction", "pykotaJobPrice", "pykotaFileName", "pykotaTitle", "pykotaCopies", "pykotaOptions", "createTimestamp"], base="cn=%s,%s" % (lastjobident, self.info["jobbase"]), scope=ldap.SCOPE_BASE) 
     596            result = self.doSearch("objectClass=pykotaJob", ["pykotaHostName", "pykotaUserName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaJobSize", "pykotaAction", "pykotaJobPrice", "pykotaFileName", "pykotaTitle", "pykotaCopies", "pykotaOptions", "createTimestamp"], base="cn=%s,%s" % (lastjobident, self.info["jobbase"]), scope=ldap.SCOPE_BASE) 
    594597            if result : 
    595598                fields = result[0][1] 
     
    605608                lastjob.JobCopies = int(fields.get("pykotaCopies", [0])[0]) 
    606609                lastjob.JobOptions = fields.get("pykotaOptions", [""])[0] 
     610                lastjob.JobHostName = fields.get("pykotaHostName", [""])[0] 
    607611                date = fields.get("createTimestamp", ["19700101000000"])[0] 
    608612                year = int(date[:4]) 
     
    912916        self.doModify(lastjob.ident, fields)          
    913917         
    914     def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None) : 
     918    def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None) : 
    915919        """Adds a job in a printer's history.""" 
    916920        if (not self.disablehistory) or (not printer.LastJob.Exists) : 
     
    932936                   "pykotaCopies" : str(copies),  
    933937                   "pykotaOptions" : str(options),  
     938                   "pykotaHostName" : str(clienthost),  
    934939                 } 
    935940        if (not self.disablehistory) or (not printer.LastJob.Exists) : 
     
    9971002            self.doModify(pgroup.ident, fields)          
    9981003             
    999     def retrieveHistory(self, user=None, printer=None, datelimit=None, limit=100) :     
     1004    def retrieveHistory(self, user=None, printer=None, datelimit=None, hostname=None, limit=100) :     
    10001005        """Retrieves all print jobs for user on printer (or all) before date, limited to first 100 results.""" 
    10011006        precond = "(objectClass=pykotaJob)" 
     
    10051010        if (printer is not None) and printer.Exists : 
    10061011            where.append("(pykotaPrinterName=%s)" % printer.Name) 
     1012        if hostname is not None : 
     1013            where.append("(pykotaHostName=%s)" % hostname) 
    10071014        if where :     
    10081015            where = "(&%s)" % "".join([precond] + where) 
     
    10101017            where = precond 
    10111018        jobs = []     
    1012         result = self.doSearch(where, fields=["pykotaUserName", "pykotaPrinterName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaAction", "pykotaJobSize", "pykotaJobPrice", "pykotaFileName", "pykotaTitle", "pykotaCopies", "pykotaOptions", "createTimestamp"], base=self.info["jobbase"]) 
     1019        result = self.doSearch(where, fields=["pykotaHostName", "pykotaUserName", "pykotaPrinterName", "pykotaJobId", "pykotaPrinterPageCounter", "pykotaAction", "pykotaJobSize", "pykotaJobPrice", "pykotaFileName", "pykotaTitle", "pykotaCopies", "pykotaOptions", "createTimestamp"], base=self.info["jobbase"]) 
    10131020        if result : 
    10141021            for (ident, fields) in result : 
     
    10241031                job.JobCopies = int(fields.get("pykotaCopies", [0])[0]) 
    10251032                job.JobOptions = fields.get("pykotaOptions", [""])[0] 
     1033                job.JobHostName = fields.get("pykotaHostName", [""])[0] 
    10261034                date = fields.get("createTimestamp", ["19700101000000"])[0] 
    10271035                year = int(date[:4])