Index: pykota/trunk/README
===================================================================
--- pykota/trunk/README (revision 882)
+++ pykota/trunk/README (revision 887)
@@ -110,4 +110,11 @@
 =============
 
+WARNING :
+=========
+
+  If you run a PyKota version lower than 1.01, you definitely have to 
+  upgrade you Quota Storage Database. Please read the documentation 
+  included in the initscripts subdirectory first ! 
+  
 Prerequisite : 
 --------------
Index: pykota/trunk/pykota/storages/sql.py
===================================================================
--- pykota/trunk/pykota/storages/sql.py (revision 873)
+++ pykota/trunk/pykota/storages/sql.py (revision 887)
@@ -21,4 +21,8 @@
 #
 # $Log$
+# Revision 1.21  2003/04/08 20:38:08  jalet
+# The last job Id is saved now for each printer, this will probably
+# allow other accounting methods in the future.
+#
 # Revision 1.20  2003/03/29 13:45:27  jalet
 # GPL paragraphs were incorrectly (from memory) copied into the sources.
@@ -148,5 +152,5 @@
     def getPrinterPageCounter(self, printername) :
         """Returns the last page counter value for a printer given its name."""
-        result = self.doQuery("SELECT pagecounter, lastusername FROM printers WHERE printername=%s;" % self.doQuote(printername))
+        result = self.doQuery("SELECT pagecounter, lastjobid, lastusername FROM printers WHERE printername=%s;" % self.doQuote(printername))
         try :
             return self.doParseResult(result)[0]
@@ -154,7 +158,7 @@
             return
         
-    def updatePrinterPageCounter(self, printername, username, pagecount) :
-        """Updates the last page counter information for a printer given its name, last username and pagecount."""
-        return self.doQuery("UPDATE printers SET pagecounter=%s, lastusername=%s WHERE printername=%s;" % (self.doQuote(pagecount), self.doQuote(username), self.doQuote(printername)))
+    def updatePrinterPageCounter(self, printername, username, pagecount, jobid) :
+        """Updates the last page counter information for a printer given its name, last username, pagecount and jobid."""
+        return self.doQuery("UPDATE printers SET pagecounter=%s, lastusername=%s, lastjobid=%s WHERE printername=%s;" % (self.doQuote(pagecount), self.doQuote(username), self.doQuote(jobid), self.doQuote(printername)))
         
     def addUserPQuota(self, username, printername) :
Index: pykota/trunk/bin/pykota
===================================================================
--- pykota/trunk/bin/pykota (revision 873)
+++ pykota/trunk/bin/pykota (revision 887)
@@ -23,4 +23,8 @@
 #
 # $Log$
+# Revision 1.16  2003/04/08 20:38:08  jalet
+# The last job Id is saved now for each printer, this will probably
+# allow other accounting methods in the future.
+#
 # Revision 1.15  2003/03/29 13:45:27  jalet
 # GPL paragraphs were incorrectly (from memory) copied into the sources.
@@ -131,4 +135,8 @@
         
     #    
+    # According to CUPS documentation, the job id is the second command line argument
+    jobid = sys.argv[1].strip()
+    
+    #    
     # According to CUPS documentation, the username is the third command line argument
     username = sys.argv[2].strip()    
@@ -155,5 +163,5 @@
     else :    
         # get last values from Quota Storage
-        (lastpagecounter, lastusername) = (pgc["pagecounter"], pgc["lastusername"])
+        (lastpagecounter, lastjobid, lastusername) = (pgc["pagecounter"], pgc["lastjobid"], pgc["lastusername"])
         
         # if printer is off then we assume the correct counter value is the last one
@@ -163,5 +171,5 @@
         # Update the last page counter and last username in the Quota Storage backend
         # set them to current user and 
-        kotafilter.storage.updatePrinterPageCounter(kotafilter.printername, username, counterbeforejob)
+        kotafilter.storage.updatePrinterPageCounter(kotafilter.printername, username, counterbeforejob, jobid)
         
         # Was the printer ever used ?
Index: pykota/trunk/initscripts/README.postgresql
===================================================================
--- pykota/trunk/initscripts/README.postgresql (revision 880)
+++ pykota/trunk/initscripts/README.postgresql (revision 887)
@@ -27,5 +27,5 @@
 
 If you have already installed PyKota, and have datas in your
-Quota Storage DataBase, you may prefer to  skip this section
+Quota Storage DataBase, you may prefer to skip this section
 and read the next one.
 
@@ -49,10 +49,15 @@
 ============================================================
 
-Upgrade script :
+Upgrade scripts :
 
-  An sql script to upgrade a pre-1.01 PyKota Quota Storage 
-  DataBase is included, if you want to keep your datas from
-  a pre-1.01 PyKota version, then please launch the following
-  commands :
+  Some scripts to upgrade old PyKota databases to the new
+  database schema are included. You may have to run all
+  of them or only some of them, depending on your 
+  version of PyKota.
+  
+* An sql script to upgrade a pre-1.01 PyKota Quota Storage DataBase to 
+  1.01 is included. If your PyKota version is equal or higher than 1.01 then
+  you can skip to the next section. Otherwise, if you want to keep your datas
+  from a pre-1.01 PyKota version, then please launch the following commands : 
   
         - Launch the psql frontend and connect to the
@@ -76,5 +81,5 @@
   to run this upgrade script.
   
-WARNING :  
+  WARNING :  
 
   This script requires a recent version of PostgreSQL to run
@@ -85,12 +90,7 @@
   fields are pagecounter and lifepagecounter, just forgot them.
   
-IMPORTANT :
-
-  Because the modifications are just about Group Print Quotas
-  and because Group Print Quotas are currently not fully   
-  implemented, you can delay the launch of this upgrade
-  script until you really need Group Print Quotas.
-  In other terms, running this script is not mandatory
-  for PyKota to continue to work correctly, at least
-  until Group Print Quotas will be fully implemented.
-  
+* If you are already running PyKota 1.01 or 1.02 and want to upgrade to 
+  1.03, YOU HAVE TO RUN the upgrade-1.01-to-1.03.sh shell script.
+  NOT LAUNCHING THIS SCRIPT WILL CAUSE PYKOTA TO STOP WORKING !
+  Please don't run this script if your version of PyKota is already
+  1.03 or higher.
Index: pykota/trunk/initscripts/pykota-postgresql.sql
===================================================================
--- pykota/trunk/initscripts/pykota-postgresql.sql (revision 873)
+++ pykota/trunk/initscripts/pykota-postgresql.sql (revision 887)
@@ -20,4 +20,8 @@
 --
 -- $Log$
+-- Revision 1.7  2003/04/08 20:38:08  jalet
+-- The last job Id is saved now for each printer, this will probably
+-- allow other accounting methods in the future.
+--
 -- Revision 1.6  2003/03/29 13:45:27  jalet
 -- GPL paragraphs were incorrectly (from memory) copied into the sources.
@@ -84,4 +88,5 @@
 CREATE TABLE printers(id SERIAL PRIMARY KEY NOT NULL,
                       printername TEXT UNIQUE NOT NULL,
+                      lastjobid TEXT,
                       lastusername TEXT,
                       pagecounter INT4 DEFAULT 0);
Index: pykota/trunk/initscripts/README
===================================================================
--- pykota/trunk/initscripts/README (revision 873)
+++ pykota/trunk/initscripts/README (revision 887)
@@ -22,13 +22,29 @@
 This directory contains scripts to initialise the PyKota
 storage database. Use the one which best suits your need
-depending on the storage backend you want to use. Each
-script has an associated README file, be sure to read 
-this as well :
+depending on the storage backend you want to use.
 
-        File                            Backend
-        --------------------------------------------------
-         pykota-posgresql.sql | PostgreSQL storage
-pykota-upgrade-postgresql.sql | Upgrade database schema from pre 1.01
-                              |
-        
-============================================================
+
+Files :
+=======
+
+  * pykota-postgresql.sql :
+  
+    This file creates an empty Quota Storage Database, using PostgreSQL
+    as a backend. You have to use it the first time you install PyKota
+    if you want to use PostgreSQL as the Quota Storage Backend.
+    
+  * pykota-upgrade-postgresql.sql :
+  
+    This files upgrades the PostgreSQL Quota Storage Database schema
+    from versions before 1.01 to version 1.01.
+    
+  * upgrade-1.01-to-1.03.sh :
+  
+    This shell script upgrades the PostgreSQL Quota Storage Database schema
+    from versions 1.01 or 1.02 to version 1.03.
+    PLEASE DO A BACKUP OF YOUR PYKOTA DATABASE BEFORE RUNNING THIS SCRIPT !
+    Also this script will try to connect to PostgreSQL as the postgres user
+    (i.e. PostgreSQL's administrator), on the local machine (PyKota Storage 
+    Server), without prompting for a password. Please read this script and 
+    adapt it to your own configuration before running it. THIS IS IMPORTANT.
+  
Index: pykota/trunk/NEWS
===================================================================
--- pykota/trunk/NEWS (revision 885)
+++ pykota/trunk/NEWS (revision 887)
@@ -24,4 +24,9 @@
     - 1.03alpha :
     
+        - IMPORTANT : DataBase schema has changed, YOU HAVE TO
+          UPGRADE using the upgrade-1.01-to-1.03.sh script.
+          Please read initscripts/README first and then 
+          read initscripts/README.postgresql
+          
         - The installation script now allows to install the sample
           configuration file during first installation.
