I'm attempting to implement a recursive directory monitor based on the GIO file monitor in PyGTK. My approach is basically to take the gio.FileMonitor returned by the method gio.File.monitor_directory(), connect to the "changed" signal, and add or remove monitors on create/ delete events for subdirectories.
I'd really like to do this by subclassing gio.FileMonitor. But the problem I'm having is that it's never explicitly initialised in user code (but somewhere in gio.File.monitor_directory() ). So there's no point in just declaring a subclass — where would I actually create an instance? Is there a way I can write the subclass but then somehow... extend an existing instance all at once rather than monkeypatch methods on one by one? So I could take an existing instance of a FileMonitor and make it an instance of my subclass? This would even allow me to override the gio.File.monitor_directory() method to take the monitor returned by the original method and decide whether to make it recursive based on a parameter passed to monitor_directory(). Cheers, Jason PS. Asked a similar question on the pygtk list a few days ago: http://www.daa.com.au/pipermail/pygtk/2010-September/018965.html -- http://mail.python.org/mailman/listinfo/python-list