Index: pykota/trunk/bin/edpykota
===================================================================
--- pykota/trunk/bin/edpykota (revision 3489)
+++ pykota/trunk/bin/edpykota (revision 3549)
@@ -36,5 +36,5 @@
 class EdPyKota(PyKotaTool) :
     """A class for edpykota."""
-    def modifyPQEntry(self, pqkey, pqentry, noquota, softlimit, hardlimit, increase, reset, hardreset, suffix, used) :
+    def modifyPQEntry(self, pqkey, pqentry, noquota, softlimit, hardlimit, increase, reset, hardreset, suffix, used, maxjobsize) :
         """Modifies a print quota entry."""
         if noquota or ((softlimit is not None) and (hardlimit is not None)) :
@@ -54,4 +54,9 @@
             if used :
                 pqentry.setUsage(used)
+            if maxjobsize is not None :
+                if maxjobsize == "unlimited" :
+                    pqentry.setMaxJobSize(None)
+                else :
+                    pqentry.setMaxJobSize(maxjobsize)
 
     def main(self, names, options) :
@@ -77,6 +82,8 @@
                                       or options.noquota \
                                       or options.increase \
+                                      or options.maxjobsize \
                                       or options.skipexisting))) \
              or (options.groups and (options.used \
+                                  or options.maxjobsize \
                                   or options.increase \
                                   or options.reset \
@@ -106,5 +113,6 @@
                         self.display("    %s\n" % (_("Hard limit : %s") % pqentry.HardLimit))
                         self.display("    %s\n" % (_("Date limit : %s") % pqentry.DateLimit))
-                        self.display("    %s (Not supported yet)\n" % (_("Maximum job size : %s") % ((pqentry.MaxJobSize and (_("%s pages") % pqentry.MaxJobSize)) or _("Unlimited"))))
+                        if suffix == "User" :
+                            self.display("    %s\n" % (_("Maximum job size : %s") % (((pqentry.MaxJobSize is not None) and (_("%s pages") % pqentry.MaxJobSize)) or _("Unlimited"))))
                         if hasattr(pqentry, "WarnCount") :
                             self.display("    %s\n" % (_("Warning banners printed : %s") % pqentry.WarnCount))
@@ -159,4 +167,17 @@
                         self.printInfo(_("Undefined soft limit set to hard limit (%s).") % str(softlimit))
 
+            if options.maxjobsize :
+                if options.maxjobsize.lower() == "unlimited" :
+                    maxjobsize = "unlimited"
+                else :
+                    try :
+                        maxjobsize = int(options.maxjobsize)
+                        if maxjobsize < 0 :
+                            raise ValueError
+                    except ValueError :
+                        raise PyKotaCommandLineError, _("Invalid maximum job size value %s") % options.maxjobsize
+            else :
+                maxjobsize = None
+
             self.storage.beginTransaction()
             try :
@@ -183,5 +204,6 @@
                                                options.hardreset,
                                                suffix,
-                                               used)
+                                               used,
+                                               maxjobsize)
                             oldpqentry = getattr(self.storage, "add%sPQuota" % suffix)(pqentry)
                             if oldpqentry is not None :
@@ -201,5 +223,6 @@
                                                        options.hardreset,
                                                        suffix,
-                                                       used)
+                                                       used,
+                                                       maxjobsize)
                                     oldpqentry.save()
                             percent.oneMore()
@@ -220,5 +243,6 @@
                                                    options.hardreset,
                                                    suffix,
-                                                   used)
+                                                   used,
+                                                   maxjobsize)
                                 pqentry.save()
                             percent.oneMore()
@@ -263,4 +287,7 @@
                             dest="action",
                             help=_("Display detailed informations about the specified users or groups print quota entries."))
+    parser.add_option("-m", "--maxjobsize",
+                            dest="maxjobsize",
+                            help=_("Set the maximum job size in pages the specified users are allowed to print to the specified printers in a single job. Accepted values are '0' to forbid printing, 'unlimited' to allow unrestricted printing, or any positive integer value. This option is not supported for users groups."))
     parser.add_option("-n", "--noquota",
                             dest="noquota",
Index: pykota/trunk/bin/pykotme
===================================================================
--- pykota/trunk/bin/pykotme (revision 3489)
+++ pykota/trunk/bin/pykotme (revision 3549)
@@ -92,5 +92,6 @@
                 userpquota = self.storage.getUserPQuota(user, printer)
                 if userpquota.Exists :
-                    if printer.MaxJobSize and (totalsize > printer.MaxJobSize) :
+                    if (printer.MaxJobSize and (totalsize > printer.MaxJobSize)) \
+                            or (userpquota.MaxJobSize and (totalsize > userpquota.MaxJobSize)) :
                         self.display("%s\n" % (_("User %(username)s is not allowed to print so many pages on printer %(printername)s at this time.") % locals()))
                     else :
Index: pykota/trunk/bin/pkprinters
===================================================================
--- pykota/trunk/bin/pkprinters (revision 3489)
+++ pykota/trunk/bin/pkprinters (revision 3549)
@@ -50,5 +50,8 @@
             printer.setPassThrough(True)
         if maxjobsize is not None :
-            printer.setMaxJobSize(maxjobsize)
+            if maxjobsize == "unlimited" :
+                printer.setMaxJobSize(None)
+            else :
+                printer.setMaxJobSize(maxjobsize)
 
     def managePrintersGroups(self, pgroups, printer, remove) :
@@ -151,5 +154,5 @@
                                      (_("Passthrough mode : %s") % ((printer.PassThrough and _("ON")) or _("OFF"))))
                 self.display("    %s\n" % \
-                                     (_("Maximum job size : %s") % ((printer.MaxJobSize and (_("%s pages") % printer.MaxJobSize)) or _("Unlimited"))))
+                                     (_("Maximum job size : %s") % (((printer.MaxJobSize is not None) and (_("%s pages") % printer.MaxJobSize)) or _("Unlimited"))))
                 self.display("    %s\n" % (_("Routed through PyKota : %s") % ((self.isPrinterCaptured(printer.Name) and _("YES")) or _("NO"))))
                 if parents :
@@ -188,10 +191,13 @@
 
             if options.maxjobsize :
-                try :
-                    maxjobsize = int(options.maxjobsize)
-                    if maxjobsize < 0 :
-                        raise ValueError
-                except ValueError :
-                    raise PyKotaCommandLineError, _("Invalid maximum job size value %s") % options.maxjobsize
+                if options.maxjobsize.lower() == "unlimited" :
+                    maxjobsize = "unlimited"
+                else :
+                    try :
+                        maxjobsize = int(options.maxjobsize)
+                        if maxjobsize < 0 :
+                            raise ValueError
+                    except ValueError :
+                        raise PyKotaCommandLineError, _("Invalid maximum job size value %s") % options.maxjobsize
             else :
                 maxjobsize = None
@@ -306,5 +312,5 @@
     parser.add_option("-m", "--maxjobsize",
                             dest="maxjobsize",
-                            help=_("Set the maximum job size in pages allowed on the specified printers."))
+                            help=_("Set the maximum job size in pages allowed on the specified printers. Accepted values are '0' to forbid printing, 'unlimited' to allow unrestricted printing, or any positive integer value."))
     parser.add_option("-n", "--nopassthrough",
                             action="store_true",
Index: pykota/trunk/bin/cupspykota
===================================================================
--- pykota/trunk/bin/cupspykota (revision 3545)
+++ pykota/trunk/bin/cupspykota (revision 3549)
@@ -557,4 +557,5 @@
         setenv("PYKOTALIFETIMEPAID", str(self.User.LifeTimePaid or 0.0), self.charset)
         setenv("PYKOTAUSERDESCRIPTION", self.User.Description or "", self.charset)
+        setenv("PYKOTAMAXJOBSIZE", ((self.UserPQuota.MaxJobSize is None) and _("Unlimited")) or str(self.UserPQuota.MaxJobSize), self.charset)
 
         setenv("PYKOTAPAGECOUNTER", str(self.UserPQuota.PageCounter or 0), self.charset)
@@ -1027,4 +1028,13 @@
                 # This printer was set to refuse jobs this large.
                 self.printInfo(_("Precomputed job size (%s pages) too large for printer %s.") % (self.softwareJobSize, self.PrinterName), "warn")
+                self.Action = "DENY"
+                # here we don't put the precomputed job size in the message
+                # because in case of error the user could complain :-)
+                self.Reason = _("You are not allowed to print so many pages on printer %s at this time.") % self.PrinterName
+
+        if self.Action not in ("DENY", "CANCEL") :
+            if (self.UserPQuota.MaxJobSize is not None) and (self.softwareJobSize > self.UserPQuota.MaxJobSize) :
+                # This user print quota entry was set to refuse jobs this large.
+                self.printInfo(_("Precomputed job size (%s pages) too large for user %s on printer %s.") % (self.softwareJobSize, self.UserName, self.PrinterName), "warn")
                 self.Action = "DENY"
                 # here we don't put the precomputed job size in the message
