Index: /pykota/trunk/conf/pykota.conf.sample
===================================================================
--- /pykota/trunk/conf/pykota.conf.sample (revision 976)
+++ /pykota/trunk/conf/pykota.conf.sample (revision 980)
@@ -62,4 +62,11 @@
 #                 default in PyKota since its beginning.
 #
+#    - external : delegates the job's size computation to any 
+#                 external command of your choice. A stupid and 
+#                 completely unreliable example, but which
+#                 shows what this command may be is :
+#
+#                   accounter: external(/bin/grep -c showpage)
+# 
 #    - stupid : counts the occurences of the 'showpage' postscript
 #               statement in the document to be printed, only at
@@ -68,6 +75,4 @@
 #               an example on how to implement your own accounting
 #               method.
-#
-#    - more to be added in the future
 #
 # This value can be set either globally or on a per printer basis
@@ -106,5 +111,7 @@
 [lp]
 
-# How to query the lp printer for its page counter, if needed
+# How to query the lp printer for its page counter.
+# THIS IS ONLY USED IF YOU HAVE SET 'accounter' TO 'querying'
+# JUST COMMENT IT OUT IF YOU USE ANY OTHER ACCOUNTING METHOD.
 # Only snmp(community, oid) and external(command) are supported
 #
Index: /pykota/trunk/README
===================================================================
--- /pykota/trunk/README (revision 958)
+++ /pykota/trunk/README (revision 980)
@@ -62,4 +62,9 @@
           "untested" directory and try to adapt them to your
           configuration.
+          
+        - External accounting methods : you can use your own accounting
+          method to compute each job's size. Just create a shell script
+          which prints the job's (read from its standard input) size on 
+          its standard output, and you're done !
         
         - Special scripts included for a seamless integration of
@@ -87,41 +92,32 @@
 Planned features are described in the TODO file.
 
-Actually only the lazy quota method is implemented. What do I call
-lazy method ?
-
-  The lazy method consists in querying the printer (actually via SNMP 
-  or Netatalk) for its total pages counter, just before the beginning 
-  of a job, and use this to modify the *preceding* user's quota. So 
-  you're always late of one print job, but this is generally ok, 
-  especially because a check is also done to see if the current user 
-  is allowed or not to print. 
-  
-  Problem may theorically arise in batches of successive print jobs by 
-  different users when there's no sleep time between two jobs : the 
-  used pages may theorically be attributed to an incorrect user in the 
-  case that the printer is asked for its page counter at the beginning 
-  of a new job and before the end of the previous job. This depends on 
-  the printer speed and time between jobs, but so far I've not seen 
-  any problem with moderately used printers. This also depends on the
-  printing system's internal behavior : if it doesn't begin to send a 
-  job to a printer before the previous one is completely printed, then 
-  there's no problem. 
-  
-  Other querying methods which won't suffer from this possible 
-  problem, but probably from other ones ;-) will be implemented in the 
-  future. 
+Actually three (or an infinity of) page accounting methods are
+implemented :
+
+  - The 'querying' method consists in querying the printer (via SNMP
+    or Netatalk) for its total pages counter, just before the beginning 
+    of a job, and use this to modify the *preceding* user's quota. So 
+    you're always late of one print job, but this is generally ok, 
+    especially because a check is also done to see if the current user 
+    is allowed or not to print. You're not limited to SNMP or Netatalk,
+    because you can also use any external command instead if you want.
+    
+  - The 'external' method consists in delegating the computation of the
+    job's size in number of pages to any external command of your choice.
+    The command can read the job's data from its standard input and MUST
+    output the job's size on its standard output.
+    
+  - The 'stupid' method consists in counting the 'showpage' PostSript  
+    statements in the job. THIS IS UNRELIABLE, but can serve as an
+    example if you plan to write your own accounting method for
+    integration into PyKota.
   
 PyKota is known to work fine with HP Laserjet 2100 and 2200, and 
-Apple LaserWriter 16/600 PS. 
-
-It should also work fine with any printer capable of outputing 
-its lifetime printed pages counter via either SNMP or AppleTalk. 
-
-If your printers don't support SNMP or AppleTalk, then making them 
-work with PyKota is up to you. Some sample scripts which can query 
-non-SNMP printers for their lifetime page counter are included in 
-the ./untested directory. You'll have to test and adapt them though, 
-and define them as external requesters in the PyKota configuration 
-file. See the sample configuration file to learn how to do that.
+Apple LaserWriter 16/600 PS, both with CUPS and LPRng, under 
+Debian GNU/Linux (Sarge and Sid) operating systems.
+
+I'm interested in receiving success or failure reports with other
+brands or models of printers, as well as with other operating 
+systems.
 
 ============================================================
@@ -261,20 +257,6 @@
     along with totals.
     
-SECURITY : You should ensure that only the print quota administrator
-           can run the warnpykota command, but this is actually not
-           enforced in the program. Any user able to launch warnpykota
-           could flood over-quota users' email boxes.
-           
-           You should ensure that only the print quota administrator
-           can run the edpykota command, but this is actually not
-           enforced in the program. Otherwise, any user could modify 
-           his/her or other people's print quota.
-          
-           launching : chmod 750 /usr/bin/warnpykota /usr/bin/edpykota
-           should make you reasonably safe.
-           
-           also please ensure that only the printing daemon user
-           can launch the pykota command. Again this is not enforced
-           in the program.
+For different security concerns, please give a look at the SECURITY
+file which is part of this software.
            
 ============================================================
Index: /pykota/trunk/pykota/accounter.py
===================================================================
--- /pykota/trunk/pykota/accounter.py (revision 976)
+++ /pykota/trunk/pykota/accounter.py (revision 980)
@@ -21,4 +21,7 @@
 #
 # $Log$
+# Revision 1.3  2003/04/30 19:53:58  jalet
+# 1.05
+#
 # Revision 1.2  2003/04/30 13:36:40  jalet
 # Stupid accounting method was added.
@@ -43,7 +46,8 @@
 class AccounterBase :    
     """A class to account print usage by querying printers."""
-    def __init__(self, kotafilter) :
+    def __init__(self, kotafilter, arguments) :
         """Sets instance vars depending on the current printer."""
         self.filter = kotafilter
+        self.arguments = arguments
         
     def filterInput(self, inputfile) :
@@ -71,5 +75,5 @@
 def openAccounter(kotafilter) :
     """Returns a connection handle to the appropriate accounter."""
-    backend = kotafilter.config.getAccounterBackend(kotafilter.printername)
+    (backend, args) = kotafilter.config.getAccounterBackend(kotafilter.printername)
     try :
         if not backend.isalpha() :
@@ -80,3 +84,3 @@
         raise PyKotaAccounterError, _("Unsupported accounter backend %s") % backend
     else :    
-        return getattr(accounterbackend, "Accounter")(kotafilter)
+        return getattr(accounterbackend, "Accounter")(kotafilter, args)
Index: /pykota/trunk/pykota/config.py
===================================================================
--- /pykota/trunk/pykota/config.py (revision 976)
+++ /pykota/trunk/pykota/config.py (revision 980)
@@ -21,4 +21,7 @@
 #
 # $Log$
+# Revision 1.26  2003/04/30 19:53:58  jalet
+# 1.05
+#
 # Revision 1.25  2003/04/30 13:36:40  jalet
 # Stupid accounting method was added.
@@ -200,12 +203,23 @@
            for its internal lifetime page counter.
         """   
-        validaccounters = [ "querying", "stupid" ]     
-        try :
-            accounter = self.getPrinterOption(printer, "accounter").lower()
-        except PyKotaConfigError :    
-            accounter = "querying"
-        if accounter not in validaccounters :
+        validaccounters = [ "querying", "stupid", "external" ]     
+        try :
+            fullaccounter = self.getPrinterOption(printer, "accounter").strip().lower()
+        except PyKotaConfigError :    
+            fullaccounter = "querying"
+        if fullaccounter.startswith("external") :    
+            try :
+                (accounter, args) = [x.strip() for x in fullaccounter.split('(', 1)]
+            except ValueError :    
+                raise PyKotaConfigError, _("Invalid external accounter %s for printer %s") % (fullaccounter, printer)
+            if args.endswith(')') :
+                args = args[:-1]
+            if not args :
+                raise PyKotaConfigError, _("Invalid external accounter %s for printer %s") % (fullaccounter, printer)
+            return (accounter, args)    
+        elif fullaccounter not in validaccounters :
             raise PyKotaConfigError, _("Option accounter in section %s only supports values in %s") % (printer, str(validaccounters))
-        return accounter
+        else :    
+            return (fullaccounter, None)
         
     def getRequesterBackend(self, printer) :    
Index: /pykota/trunk/pykota/version.py
===================================================================
--- /pykota/trunk/pykota/version.py (revision 976)
+++ /pykota/trunk/pykota/version.py (revision 980)
@@ -21,5 +21,5 @@
 #
 
-__version__ = "1.05alpha3-unofficial"
+__version__ = "1.05-unofficial"
 
 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""
Index: /pykota/trunk/NEWS
===================================================================
--- /pykota/trunk/NEWS (revision 978)
+++ /pykota/trunk/NEWS (revision 980)
@@ -22,4 +22,20 @@
 PyKota NEWS :
 
+    - 1.05 :
+    
+        - External accounters are finally available !
+          This means that you can plug any page accounting
+          method you like by setting the appropriate
+          'accounter' field in /etc/pykota.conf
+          See the sample conf/pykota.conf.sample to 
+          learn how to do.
+          
+          NB : Both 'external' and 'stupid' accounting methods
+               account a job size just before *this* job is 
+               sent to the printer. 
+               The original 'querying' method accounts a job
+               size just before *the next* job is sent to
+               the printer.
+        
     - 1.05alpha3 :
     
Index: /pykota/trunk/po/en/pykota.po
===================================================================
--- /pykota/trunk/po/en/pykota.po (revision 976)
+++ /pykota/trunk/po/en/pykota.po (revision 980)
@@ -21,4 +21,7 @@
 #
 # $Log$
+# Revision 1.24  2003/04/30 19:53:58  jalet
+# 1.05
+#
 # Revision 1.23  2003/04/30 13:36:40  jalet
 # Stupid accounting method was added.
@@ -343,2 +346,8 @@
 msgid "Using the 'stupid' accounting method is unreliable."
 msgstr ""
+
+msgid "Invalid external accounter %s for printer %s"
+msgstr ""
+
+msgid "Unable to compute job size with external accounter %s"
+msgstr ""
Index: /pykota/trunk/po/fr/pykota.po
===================================================================
--- /pykota/trunk/po/fr/pykota.po (revision 976)
+++ /pykota/trunk/po/fr/pykota.po (revision 980)
@@ -21,4 +21,7 @@
 #
 # $Log$
+# Revision 1.23  2003/04/30 19:53:58  jalet
+# 1.05
+#
 # Revision 1.22  2003/04/30 13:36:40  jalet
 # Stupid accounting method was added.
@@ -355,2 +358,8 @@
 msgid "Using the 'stupid' accounting method is unreliable."
 msgstr "Utiliser la m�ode 'stupid' n'est pas fiable."
+
+msgid "Invalid external accounter %s for printer %s"
+msgstr "Compteur de pages externe %s invalide pour l'imprimante %s"
+
+msgid "Unable to compute job size with external accounter %s"
+msgstr "Impossible de calculer la taille du job avec le compteur externe %s"
Index: /pykota/trunk/po/pykota.pot
===================================================================
--- /pykota/trunk/po/pykota.pot (revision 976)
+++ /pykota/trunk/po/pykota.pot (revision 980)
@@ -21,4 +21,7 @@
 #
 # $Log$
+# Revision 1.24  2003/04/30 19:53:58  jalet
+# 1.05
+#
 # Revision 1.23  2003/04/30 13:36:40  jalet
 # Stupid accounting method was added.
@@ -343,2 +346,8 @@
 msgid "Using the 'stupid' accounting method is unreliable."
 msgstr ""
+
+msgid "Invalid external accounter %s for printer %s"
+msgstr ""
+
+msgid "Unable to compute job size with external accounter %s"
+msgstr ""
