Show
Ignore:
Timestamp:
10/08/03 23:41:38 (21 years ago)
Author:
jalet
Message:

External policies for printers works !
We can now auto-add users on first print, and do other useful things if needed.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/config.py

    r1148 r1152  
    2222# 
    2323# $Log$ 
     24# Revision 1.39  2003/10/08 21:41:38  jalet 
     25# External policies for printers works ! 
     26# We can now auto-add users on first print, and do other useful things if needed. 
     27# 
    2428# Revision 1.38  2003/10/07 22:06:05  jalet 
    2529# Preliminary code to disable job history 
     
    320324    def getPrinterPolicy(self, printer) :     
    321325        """Returns the default policy for the current printer.""" 
    322         validpolicies = [ "ALLOW", "DENY" ]      
    323         try : 
    324             policy = self.getPrinterOption(printer, "policy").upper() 
    325         except PyKotaConfigError :     
    326             policy = "DENY" 
    327         if policy not in validpolicies : 
    328             raise PyKotaConfigError, _("Option policy in section %s only supports values in %s") % (printer, str(validpolicies)) 
    329         return policy 
     326        validpolicies = [ "ALLOW", "DENY", "EXTERNAL" ]      
     327        try : 
     328            fullpolicy = self.getPrinterOption(printer, "policy") 
     329        except PyKotaConfigError :     
     330            return ("DENY", None) 
     331        else :     
     332            try : 
     333                policy = [x.strip() for x in fullpolicy.split('(', 1)] 
     334            except ValueError :     
     335                raise PyKotaConfigError, _("Invalid policy %s for printer %s") % (fullpolicy, printer) 
     336            if len(policy) == 1 :     
     337                policy.append("") 
     338            (policy, args) = policy     
     339            if args.endswith(')') : 
     340                args = args[:-1] 
     341            policy = policy.upper()     
     342            if (policy == "EXTERNAL") and not args : 
     343                raise PyKotaConfigError, _("Invalid policy %s for printer %s") % (fullpolicy, printer) 
     344            if policy not in validpolicies : 
     345                raise PyKotaConfigError, _("Option policy in section %s only supports values in %s") % (printer, str(validpolicies)) 
     346            return (policy, args) 
    330347         
    331348    def getSMTPServer(self) :