1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
This a Gnome VFS module written in python that lets you browse python modules and objects.
How to test:
------------
cp pyfs.conf ~/.gnome2/vfs/modules/
export PYTHONPATH=$(pwd):$PYTHONPATH
mkdir /tmp/testing
export TMPDIR=/tmp/testing
nautilus --no-desktop pyfs:///
You will be presented with a list of modules and you can navigate
modules/objects. Notice that only currently imported modules appear
initially, but if you hit Ctr-L you can force browsing of particular
modules by entering pyfs:///<module> as URL. For example,
pyfs:///gtk/gdk will let you browse the module gtk.gdk.
How does GnomeVFS decide to use your module:
--------------------------------------------
Suppose you want to register some code to handle 'pyfs://'. You put
"pyfs: pythonmethod" in a gnome-vfs configuration file[1]. Therefore,
when a pyfs:// URI is requested, gnome-vfs loads libpythonmethod.so,
which receives the 'pyfs' method name and then tries to import the
python module 'pyfs'. The standard python path, plus
$(libdir)/gnome-vfs-2.0/modules, is searched for the module. In this
module, it looks for a class called 'pyfs_method'. It then creates a
new instance of this class, and tries to get the vfs_xxxx methods,
which are then used to implement the VFS operations.
Caveat: currently the class has to be an old-style class, so don't
subclass object.
[1] As you are asked to do in the "How to test" section; but notice
that to install it system-wide you have to copy the file to
/etc/gnome-vfs-2.0/modules/ instead of ~/.gnome2/vfs/modules/.
|