Changeset 2385

Show
Ignore:
Timestamp:
07/25/05 19:13:11 (19 years ago)
Author:
jerome
Message:

Added two new directives :

unknown_billingcode : defines what to do when printing if the billing code

used is not present in the database.

overwrite_jobticket : defines a command to launch when overwriting the username

or the billing code used is desirable (for example when
an user interaction should take place, see the work
of George Farris)

Severity : no support for this in the backend right now, so be patient (again).

Location:
pykota/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/conf/pykota.conf.sample

    r2355 r2385  
    307307# If both are defined, the printer option has priority. 
    308308# striptitle : smbprn.?????? 
     309 
     310# Should we launch a command to overwrite the job's ticket ? 
     311# This allows a command to overwrite the username and/or the 
     312# billing code used. 
     313# If unset no command is launched and the job's username and 
     314# billing code are used as they are received. 
     315# If set, the command is launched. 
     316# To overwrite the job's ticket, the command has to print 
     317# on its standard output one or more of the following lines, 
     318# without any prefix or space character : 
     319# 
     320#    USERNAME=the_username_we_want_to_overwrite_with 
     321#    BILLINGCODE=the_billingcode_we_want_to_overwrite_with 
     322# 
     323# NB : the output is entirely read, and the latest value 
     324# seen is used, so you command can output several usernames 
     325# or billing codes and only the latest ones will be used. 
     326# If only USERNAME= lines are printed, the billing code, 
     327# if any, is used unchanged. 
     328# If only BILLINGCODE= lines are printed, the username is 
     329# used unchanged. 
     330# 
     331# This value can be set either globally or on a per printer basis 
     332# If both are defined, the printer option has priority. 
     333# 
     334# overwrite_jobticket : /path/to/some/script/or/command 
     335 
     336# What should we do when we print and the billing code used is 
     337# not present in the database ? 
     338# The default value is 'create' which adds the billing code to the 
     339# database. 
     340# Other values can be : 
     341#       deny 
     342#     which silently rejects the job. 
     343# or : 
     344#       deny(your script here) 
     345#     if you put the path to a script or command here, it is executed, for 
     346#     example you can open a popup window explaining why the job was 
     347#     rejected. 
     348# 
     349# This value can be set either globally or on a per printer basis 
     350# If both are defined, the printer option has priority. 
     351# 
     352# unknown_billingcode : create 
    309353 
    310354# What is the accounting backend to use 
  • pykota/trunk/pykota/config.py

    r2370 r2385  
    205205            return      # No prefix to strip off 
    206206             
     207    def getOverwriteJobTicket(self, printername) :         
     208        """Returns the overwrite_jobticket directive's content, or None if unset.""" 
     209        try : 
     210            return self.getPrinterOption(printername, "overwrite_jobticket").strip() 
     211        except PyKotaConfigError :     
     212            return      # No overwriting will be done 
     213         
     214    def getUnknownBillingCode(self, printername) :         
     215        """Returns the unknown_billingcode directive's content, or the default value if unset.""" 
     216        validvalues = [ "CREATE", "DENY" ] 
     217        try : 
     218            fullvalue = self.getPrinterOption(printername, "unknown_billingcode") 
     219        except PyKotaConfigError :     
     220            return ("CREATE", None) 
     221        else :     
     222            try : 
     223                value = [x.strip() for x in fullvalue.split('(', 1)] 
     224            except ValueError :     
     225                raise PyKotaConfigError, _("Invalid unknown_billingcode directive %s for printer %s") % (fullvalue, printername) 
     226            if len(value) == 1 :     
     227                value.append("") 
     228            (value, args) = value     
     229            if args.endswith(')') : 
     230                args = args[:-1] 
     231            value = value.upper()     
     232            if (value == "DENY") and not args : 
     233                return ("DENY", None) 
     234            if value not in validvalues : 
     235                raise PyKotaConfigError, _("Directive unknown_billingcode in section %s only supports values in %s") % (printername, str(validvalues)) 
     236            return (value, args) 
     237         
    207238    def getPrinterEnforcement(self, printername) :     
    208239        """Returns if quota enforcement should be strict or laxist for the current printer."""