Re: [gamin] python binding question
- From: Daniel Veillard <veillard redhat com>
- To: Narayan Desai <desai mcs anl gov>
- Cc: gamin-list gnome org
- Subject: Re: [gamin] python binding question
- Date: Sun, 6 Feb 2005 06:51:11 -0500
On Sat, Feb 05, 2005 at 11:18:46PM -0600, Narayan Desai wrote:
> I have an app that uses python-fam (an abandoned set of python
> bindings to the sgi fam library) to coherently cache files. I have
> started looking at moving to gamin, and have run into a problem. In
> the python-fam package, FamEvents have three useful parts: filename
> (similar to the callback path), code2str (which converts the action to
> a string), and a handle ID (which describes the context of the
> event). I find myself frequently monitoring directory hierarchies,
> which requires the use of the handle ID to properly route the
> event.
We are doing that too, but store the id in the object receiving the
callback. Note that when you register a file or directory monitor
you pass a callback and an optional argument. That optional argument
is provided in the callback if non None.
> Is there an undocumented analogue to the handle ID in gamin's
> native bindings? Am I approaching this from the wrong angle? While I
Undocumented would require an existing documentation.
But reading the 200 lines of gamin.py should allow to quickly realize
the full capacity of the wrapper.
> support I could define a different callback function to call from each
> directory (thus removing the need for a handle ID), this approach
> strikes me as being a fairly terrible hack...
Keep the same callback, but pass a different data:
def watch_directory(self, directory, callback, data = None):
def watch_file(self, file, callback, data = None):
and make sure to define an optional arg to your callback, that arg
is an even simpler version of your ID.
Daniel
--
Daniel Veillard | Red Hat Desktop team http://redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]