Index: pykota/trunk/bin/dumpykota
===================================================================
--- pykota/trunk/bin/dumpykota (revision 2216)
+++ pykota/trunk/bin/dumpykota (revision 2218)
@@ -88,4 +88,6 @@
          printername    Printer's name
          pgroupname     Printers group's name
+         hostname       Client's hostname
+         billingcode    Job's billing code
          
   Contrary to other PyKota management tools, wildcard characters are not 
Index: pykota/trunk/NEWS
===================================================================
--- pykota/trunk/NEWS (revision 2217)
+++ pykota/trunk/NEWS (revision 2218)
@@ -24,4 +24,7 @@
     - 1.22alpha8 :
     
+        - The data dumper now accepts billingcode= and hostname= as
+          filters when dumping the job history.
+          
         - The job billing code if present is now saved into the database,
           and exported to subprocesses as the PYKOTAJOBBILLING environment
Index: pykota/trunk/pykota/dumper.py
===================================================================
--- pykota/trunk/pykota/dumper.py (revision 2217)
+++ pykota/trunk/pykota/dumper.py (revision 2218)
@@ -61,4 +61,6 @@
                         "printername",
                         "pgroupname",
+                        "hostname",
+                        "billingcode",
                       ]
     def main(self, arguments, options, restricted=1) :
@@ -75,5 +77,5 @@
                         raise ValueError                
                 except ValueError :    
-                    raise PyKotaToolError, _("Invalid value [%s] for --filter command line option, see help.") % filterexp
+                    raise PyKotaToolError, _("Invalid filter value [%s], see help.") % filterexp
                 else :    
                     extractonly.update({ filterkey : filtervalue })
@@ -91,5 +93,5 @@
             raise PyKotaToolError, _("XML output is disabled because the jaxml module is not available.")
             
-        entries = getattr(self.storage, "extract%s" % datatype.title())(extractonly)    
+        entries = getattr(self.storage, "extract%s" % datatype.title())(extractonly)
         if entries :
             mustclose = 0    
Index: pykota/trunk/pykota/storages/sql.py
===================================================================
--- pykota/trunk/pykota/storages/sql.py (revision 2217)
+++ pykota/trunk/pykota/storages/sql.py (revision 2218)
@@ -47,5 +47,5 @@
             expressions = []
             for (k, v) in only.items() :
-                expressions.append("%s=%s" % (k, self.doQuote(v)))
+                expressions.append("%s=%s" % (k, self.doQuote(self.userCharsetToDatabase(v))))
             return " AND ".join(expressions)     
         return ""        
Index: pykota/trunk/pykota/storages/ldapstorage.py
===================================================================
--- pykota/trunk/pykota/storages/ldapstorage.py (revision 2217)
+++ pykota/trunk/pykota/storages/ldapstorage.py (revision 2218)
@@ -1037,5 +1037,5 @@
             self.doModify(pgroup.ident, fields)         
             
-    def retrieveHistory(self, user=None, printer=None, datelimit=None, hostname=None, limit=100) :    
+    def retrieveHistory(self, user=None, printer=None, datelimit=None, hostname=None, billingcode=None, limit=100) :
         """Retrieves all print jobs for user on printer (or all) before date, limited to first 100 results."""
         precond = "(objectClass=pykotaJob)"
@@ -1047,4 +1047,6 @@
         if hostname is not None :
             where.append("(pykotaHostName=%s)" % hostname)
+        if billingcode is not None :
+            where.append("(pykotaBillingCode=%s)" % self.userCharsetToDatabase(billingcode))
         if where :    
             where = "(&%s)" % "".join([precond] + where)
@@ -1326,5 +1328,5 @@
         else :    
             printer = None
-        entries = self.retrieveHistory(user, printer, limit=None)
+        entries = self.retrieveHistory(user, printer, hostname=extractonly.get("hostname"), billingcode=extractonly.get("billingcode"), limit=None)
         if entries :
             result = [ ("username", "printername", "dn", "jobid", "pagecounter", "jobsize", "action", "jobdate", "filename", "title", "copies", "options", "jobprice", "hostname", "jobsizebytes", "md5sum", "pages", "billingcode") ] 
