Changeset 2153 for pykota/trunk

Show
Ignore:
Timestamp:
03/09/05 00:01:26 (20 years ago)
Author:
jerome
Message:

First working version of web enabled print quote generator.

Location:
pykota/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/cgi-bin/pykotme.cgi

    r2152 r2153  
    2929import cgi 
    3030import urllib 
     31import cStringIO 
    3132 
    3233from pykota import version 
     
    4445  </head> 
    4546  <body> 
    46     <form action="pykotme.cgi" method="POST"> 
     47    <form action="pykotme.cgi" method="POST" enctype="multipart/form-data"> 
    4748      <table> 
    4849        <tr> 
     
    9192            self.body = '<p><font color="red">%s</font></p>\n%s' % (message, self.body) 
    9293         
    93 #    def htmlListPrinters(self, selected=[], mask="*") :     
    94 #        """Displays the printers multiple selection list.""" 
    95 #        printers = self.storage.getMatchingPrinters(mask) 
    96 #        selectednames = [p.Name for p in selected] 
    97 #        message = '<table><tr><td valign="top">%s :</td><td valign="top"><select name="printers" multiple="multiple">' % _("Printer") 
    98 #        for printer in printers : 
    99 #            if printer.Name in selectednames : 
    100 #                message += '<option value="%s" selected="selected">%s (%s)</option>' % (printer.Name, printer.Name, printer.Description) 
    101 #            else : 
    102 #                message += '<option value="%s">%s (%s)</option>' % (printer.Name, printer.Name, printer.Description) 
    103 #        message += '</select></td></tr></table>' 
    104 #        return message 
     94    def htmlListPrinters(self, selected=[], mask="*") :     
     95        """Displays the printers multiple selection list.""" 
     96        printers = self.storage.getMatchingPrinters(mask) 
     97        selectednames = [p.Name for p in selected] 
     98        message = '<table><tr><td valign="top">%s :</td><td valign="top"><select name="printers" multiple="multiple">' % _("Printer") 
     99        for printer in printers : 
     100            if printer.Name in selectednames : 
     101                message += '<option value="%s" selected="selected">%s (%s)</option>' % (printer.Name, printer.Name, printer.Description) 
     102            else : 
     103                message += '<option value="%s">%s (%s)</option>' % (printer.Name, printer.Name, printer.Description) 
     104        message += '</select></td></tr></table>' 
     105        return message 
    105106         
    106107    def guiAction(self) : 
    107108        """Main function""" 
    108         printers = None 
     109        printers = inputfile = None 
    109110        self.body = "<p>%s</p>\n" % _("Please click on the above button") 
    110111        if self.form.has_key("report") : 
     
    116117            else :     
    117118                printers = self.storage.getMatchingPrinters("*") 
     119            if self.form.has_key("inputfile") :     
     120                inputfile = self.form["inputfile"].value 
    118121                 
    119         #self.body += self.htmlListPrinters(printers or [])             
    120         #self.body += "<br />" 
     122        self.body += self.htmlListPrinters(printers or [])             
     123        self.body += "<br />" 
     124        self.body += _("Filename") + " : " 
     125        self.body += '<input type="file" size="64" name="inputfile" />' 
     126        self.body += "<br />" 
     127        if inputfile : 
     128            try : 
     129                parser = PDLAnalyzer(cStringIO.StringIO(inputfile)) 
     130                jobsize = parser.getJobSize() 
     131            except PDLAnalyzerError, msg :     
     132                self.body += '<font color="red">%s</font>' % msg 
     133            else :     
     134                self.body += _("This file is %i pages long.") % jobsize 
    121135             
    122136if __name__ == "__main__" : 
  • pykota/trunk/cgi-bin/README

    r2146 r2153  
    2525Be sure to restrict access to these CGI scripts as necessary. 
    2626 
     27For now, pykotme.cgi doesn't need any restriction. 
     28 
    2729If you protect access to printquota.cgi or dumpykota.cgi with  
    2830username+password authentication, the REMOTE_USER CGI environment variable 
  • pykota/trunk/README

    r2151 r2153  
    200200          More to come. 
    201201           
    202         - Web based print quota monitor and data dumper are included.   
     202        - Web enabled print quota monitor, data dumper, and print quote 
     203          generator. 
    203204         
    204205        - An On Screen Display X-Window print quota monitor is included. 
  • pykota/trunk/tests/master.ps.gz

    • Property svn:binary set to on