Changeset 1152 for pykota/trunk/pykota

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.

Location:
pykota/trunk/pykota
Files:
3 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) :     
  • pykota/trunk/pykota/tool.py

    r1144 r1152  
    2222# 
    2323# $Log$ 
     24# Revision 1.53  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.52  2003/10/07 09:07:28  jalet 
    2529# Character encoding added to please latest version of Python 
     
    435439                 
    436440        # then we check the user's own quota 
    437         policy = self.config.getPrinterPolicy(printer.Name) 
     441        # if we get there we are sure that policy is not EXTERNAL 
     442        (policy, dummy) = self.config.getPrinterPolicy(printer.Name) 
    438443        if user.LimitBy and (user.LimitBy.lower() == "balance") :  
    439444            if user.AccountBalance is None : 
  • pykota/trunk/pykota/version.py

    r1149 r1152  
    2222# 
    2323 
    24 __version__ = "1.15alpha8_unofficial" 
     24__version__ = "1.15alpha9_unofficial" 
    2525 
    2626__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""