Index: pykota/trunk/bin/cupspykota
===================================================================
--- pykota/trunk/bin/cupspykota (revision 2687)
+++ pykota/trunk/bin/cupspykota (revision 2692)
@@ -40,4 +40,6 @@
 from email.MIMEText import MIMEText
 from email.Header import Header
+
+from mx import DateTime
 
 from pykota.tool import PyKotaTool, PyKotaToolError, crashed
@@ -768,30 +770,42 @@
         if not denyduplicates :
             self.logdebug("We don't care about duplicate jobs after all.")
-        elif self.Printer.LastJob.Exists \
-             and (self.Printer.LastJob.UserName == self.UserName) \
-             and (self.Printer.LastJob.JobMD5Sum == self.JobMD5Sum) :
-            # TODO : use the current user's last job instead of  
-            # TODO : the current printer's last job. This would be
-            # TODO : better but requires an additional database query
-            # TODO : with SQL, and is much more complex with the 
-            # TODO : actual LDAP schema. Maybe this is not very
-            # TODO : important, because usually duplicate jobs are sucessive.
-            msg = _("Job is a dupe")
-            if denyduplicates == 1 :
-                self.printInfo("%s : %s." % (msg, _("Printing is denied by configuration")), "warn")
-                self.Action = "DENY"
-                self.Reason = _("Duplicate print jobs are not allowed on printer %s.") % self.PrinterName
-            else :    
-                self.logdebug("Launching subprocess [%s] to see if duplicate jobs should be allowed or not." % denyduplicates)
-                fanswer = os.popen(denyduplicates, "r")
-                self.Action = fanswer.read().strip().upper()
-                fanswer.close()
-                if self.Action == "DENY" :     
-                    self.printInfo("%s : %s." % (msg, _("Subprocess denied printing of a dupe")), "warn")
-                    self.Reason = _("Duplicate print jobs are not allowed on printer %s at this time.") % self.PrinterName
-                else :    
-                    self.printInfo("%s : %s." % (msg, _("Subprocess allowed printing of a dupe")), "warn")
-        else :            
-            self.logdebug("Job doesn't seem to be a duplicate.")
+        else :
+            if self.Printer.LastJob.Exists \
+                    and (self.Printer.LastJob.UserName == self.UserName) \
+                    and (self.Printer.LastJob.JobMD5Sum == self.JobMD5Sum) :
+                now = DateTime.now()
+                try :
+                    previous = DateTime.ISO.ParseDateTime(self.Printer.LastJob.JobDate).localtime()
+                except :
+                    previous = now
+                difference = (now - previous).seconds
+                duplicatesdelay = self.config.getDuplicatesDelay(self.PrinterName)
+                self.logdebug("Difference with previous job : %.2f seconds. Duplicates delay : %.2f seconds." % (difference, duplicatesdelay))
+                if difference > duplicatesdelay :
+                    self.logdebug("Duplicate job allowed because previous one is more than %.2f seconds old." % duplicatesdelay)
+                else :
+                    # TODO : use the current user's last job instead of  
+                    # TODO : the current printer's last job. This would be
+                    # TODO : better but requires an additional database query
+                    # TODO : with SQL, and is much more complex with the 
+                    # TODO : actual LDAP schema. Maybe this is not very
+                    # TODO : important, because usually duplicate jobs are sucessive.
+                    msg = _("Job is a dupe")
+                    if denyduplicates == 1 :
+                        self.printInfo("%s : %s." % (msg, _("Printing is denied by configuration")), "warn")
+                        self.Action = "DENY"
+                        self.Reason = _("Duplicate print jobs are not allowed on printer %s.") % self.PrinterName
+                    else :    
+                        self.logdebug("Launching subprocess [%s] to see if duplicate jobs should be allowed or not." % denyduplicates)
+                        fanswer = os.popen(denyduplicates, "r")
+                        self.Action = fanswer.read().strip().upper()
+                        fanswer.close()
+                        if self.Action == "DENY" :     
+                            self.printInfo("%s : %s." % (msg, _("Subprocess denied printing of a dupe")), "warn")
+                            self.Reason = _("Duplicate print jobs are not allowed on printer %s at this time.") % self.PrinterName
+                        else :    
+                            self.printInfo("%s : %s." % (msg, _("Subprocess allowed printing of a dupe")), "warn")
+            else :            
+                self.logdebug("Job doesn't seem to be a duplicate.")
         self.logdebug("Checking if the job is a duplicate done.")
         
