Re: pyphany and strange caching



On Sun, 2005-07-24 at 16:55 +0100, Magnus Therning wrote:
> For development purposes I use links from
> /usr/lib/epiphany-1.6/extensions (root is required to write there) to my
> home dir.

(Crispin already gave better solutions....)

>  /home/prog/my_lib/
> 	__init__.py
> 	...
> 
> I have a problem with making changes to files in my_lib. It seems
> Epiphany doesn't care about the fact that changes have been made. This
> manifests itself in the way that I get exceptions on lines that don't
> exist, or are empty. Shutting down Epiphany and re-starting it doesn't
> help.

First of all, how do you shut down and restart Epiphany? My guess is
that it's still running somewhere (check with "ps ax"). To shut down
Epiphany you have to close *all* browser windows. And if your Python
extension adds an extra reference to an EphyWindow or something, it's
possible that Epiphany will never shut down without being killed
("killall epiphany"). (Python extensions are far from "safe", and this
kind of error can indeed appear during development; if this is the case,
you'll have to debug your extension -- we can help, of course.)

Epiphany automatically unloads and re-loads an *extension* when its file
changes; since you're using symlinks, I don't think that feature will
work, but if you put your .py and .xml in ~/.gnome2/epiphany/extensions
directly (not symlinked), you'll benefit from that.

As for the *module*: There is a single Python instance running for the
duration of the browser session, but within Python there are ways to
reload a module. The easiest thing to do would be to open up the Python
console and type something like "import my_lib; reload(my_lib)".
Disclaimer: I haven't tested this, I'm just assuming it'll work. You
could put a "print" statement at the top of your my_lib/__init__.py to
check -- it should be printed to the Python console when you reload the
module.

To achieve better upgradeability in your extension, you might want to
check before loading the module if it is already loaded. For instance,
instead of just "import my_lib" in your extension, maybe this:

import sys
if 'my_lib' in sys.modules.keys():
    my_lib = sys.modules['my_lib']
    reload(my_lib)
else:
    import my_lib

Then you could reload the entire extension by either using Epiphany's
built-in Extensions Manager (un-checking and re-checking the checkbox)
or by running "touch ~/.gnome2/epiphany/extensions/my_extension.py" on a
console.

Good luck! Sorry, I haven't tested any of the things I've suggested in
this email, but I think they could work :).

-- 
Adam Hooper <adamh densi com>

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]