Discussion:
[pyxpcom] Accessing XBL elements from Python
Rasjid Wilcox
2009-03-29 10:39:33 UTC
Permalink
Hi all,

I've done a first pass at creating a generic way of accessing XBL
elements from Python. It uses an XPCOM component written in
Javascript and a Python library to proxy the elements. I've only
tested it so far with the 'browser' element, but there is no element
specific code, so it should work quite generally.

I've got almost everything working as expected. One can access all
the attributes, properties and methods of the element. I've even been
able to (in this case) pass a class instance implementing
WebProgressListener written in Python to the addProgressListener
method. This is the only part (so far) that does not work reliably.
It will work for a short while, and then just stop responding.
Manually re-adding the listener causes it to work again. So my
feeling is that somewhere something goes out of scope and gets garbage
collected.

In total it is currently about 200 lines of code. I'm thinking of
re-writing it in an even more general manner, ideally to get full
access to the Javascript namespace. But if anyone is interested in
looking at the code and making suggestions, I will put the code up
somewhere for people to look at.

Cheers,

Rasjid.
Rasjid Wilcox
2009-03-30 15:41:44 UTC
Permalink
Post by Rasjid Wilcox
I've even been
able to (in this case) pass a class instance implementing
WebProgressListener written in Python to the addProgressListener
method.  This is the only part (so far) that does not work reliably.
It will work for a short while, and then just stop responding.
I've now managed to fix this. Keeping a reference to the Python
function on the javascript side solved the problem.

Cheers,

Rasjid.

Loading...