Index: pkipplib/trunk/notifiers/samplenotifier
===================================================================
--- pkipplib/trunk/notifiers/samplenotifier (revision 35)
+++ pkipplib/trunk/notifiers/samplenotifier (revision 35)
@@ -0,0 +1,41 @@
+#! /usr/bin/env python
+# -*- coding: ISO-8859-15 -*-
+#
+
+"""This command can be placed in /usr/lib/cups/notifier and
+used as the notifications' recipient when creating IPP subscriptions.
+
+It will automatically ensures that each time a printer is added or
+removed from CUPS it is also added or removed from PyKota's database.
+
+IMPORTANT : because of a bug in CUPS 1.2.1, this command only works
+the first time a notification is sent."""
+
+import sys
+import os
+import fcntl
+
+from pkipplib import pkipplib
+
+if __name__ == "__main__" :
+    #
+    # First thing we do is put stdin in non-blocking mode.
+    fd = sys.stdin.fileno()
+    fcntl.fcntl(sys.stdin.fileno(), fcntl.F_SETFL, 
+                    fcntl.fcntl(fd, fcntl.F_GETFL) | os.O_NONBLOCK)
+
+    # then we read the notification CUPS sent us to our stdin
+    notification = pkipplib.IPPRequest(sys.stdin.read())
+    
+    # now we parse it
+    notification.parse()
+    
+    # then we act one way or another, depending on the event received.
+    event = notification.event_notification["notify-subscribed-event"][0][1]
+    if event in ("printer-added", "printer-deleted") :
+        printername = notification.event_notification["printer-name"][0][1]
+        if event.endswith("-added") :
+            action = "add"
+        else :    
+            action = "delete"
+        os.system('/usr/bin/pkprinters --%s "%s"' % (action, printername))
Index: pkipplib/trunk/pkipplib/pkipplib.py
===================================================================
--- pkipplib/trunk/pkipplib/pkipplib.py (revision 30)
+++ pkipplib/trunk/pkipplib/pkipplib.py (revision 35)
@@ -716,5 +716,16 @@
                                       timeinterval=None,
                                       jobid=None) :
-        """Creates a job, printer or server subscription."""
+        """Creates a job, printer or server subscription.
+         
+           uri : the subscription's uri, e.g. ipp://server
+           events : a list of events to subscribe to, e.g. ["printer-added", "printer-deleted"]
+           recipient : the notifier's uri
+           pullmethod : the pull method to use
+           charset : the charset to use when sending notifications
+           naturallanguage : the language to use when sending notifications
+           leaseduration : the duration of the lease in seconds
+           timeinterval : the interval of time during notifications
+           jobid : the optional job id in case of a job subscription
+        """   
         if jobid is not None :
             opid = IPP_CREATE_JOB_SUBSCRIPTION
@@ -746,5 +757,10 @@
             
     def cancelSubscription(self, uri, subscriptionid, jobid=None) :    
-        """Cancels a subscription."""
+        """Cancels a subscription.
+        
+           uri : the subscription's uri.
+           subscriptionid : the subscription's id.
+           jobid : the optional job's id.
+        """
         req = self.newRequest(IPP_CANCEL_SUBSCRIPTION)
         if jobid is not None :
Index: pkipplib/trunk/README
===================================================================
--- pkipplib/trunk/README (revision 34)
+++ pkipplib/trunk/README (revision 35)
@@ -142,5 +142,6 @@
   pkipplib currently includes the following command line tools :
   
-        - pksubscribe : can create or delete IPP subscriptions.
+    * pksubscribe : can create or delete IPP subscriptions.
+    
           See pksubscribe --help for details.
         
@@ -155,4 +156,11 @@
                           --password HacKMe \
                           --delete 34 58 98
+                          
+    * samplenotifier : can handle printer-added and printer-deleted
+      notifications and automatically create or remove printers
+      from PyKota's database (just adapt the code for other needs).
+      
+      samplenotifier is present in the notifiers/ directory, but
+      won't be installed automatically.
 
   In the future more command line tools will be included.
