Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

olpc python hulahop

3 views
Skip to first unread message

lkcl

unread,
Jun 12, 2009, 7:26:18 AM6/12/09
to
dear xpcom developers,
i'm posting this here because it is incredibly hard to find
information about working with xpcom / xul from python, and i've seen
unanswered posts dating back to 2006 asking "how do i use python
xpcom, how do i use python xpcom, i want to do DOM manipulation, how
can i access the DOM". well, you use it like this:
http://lkcl.net/pyjamas/python-xpcom.tgz
python-xpcom itself is missing some critical functionality that makes
it difficult to access, and this has been addressed by hulahop. on
debian-based systems, you just do "apt-get install python-hulahop" and
the example code above will just work.
included is an event handler for "click", it just prints out a message
on stdout rather than doing anything on-screen. the code isn't
perfect: i haven't yet been able to activate DOM manipulation at
exactly the appropriate point (which the olpc / sugar developers say
should be done with a loader-listener) so i added a timer of 500ms
instead.
using DOM manipulation, the background CSS style is changed to green,
and a div containing a Text node with the words "hello world" are
added to the empty page.

this is _literally_ the only example of purely using python "from
scratch" in this way to fire up and manipulate the DOM model of a XUL
engine in a "declarative" fashion.

all other examples treat XUL as some sort of "stupid web engine", or
trigger python from event handling, or treat python as a second-class
citizen by adding it as a language extension to < script > nodes, etc.

not even the sugar OLPC web browser "activity" does any DOM
manipulation or node / window / XmlHttpRequest event handling, but
uses python-hulahop to get at other parts of the XUL interface.

if anyone reading this is curious as to what it is equivalent to, in,
say, other web engine technology: python-hulahop is equivalent to
pykhtml and also to pywebkitgtk when patched with glib / gobject
bindings to the DOM.

http://paul.giannaros.org/pykhtml/ - it's listed as a "web scraper"
but can actually be used for GUI purposes: the only down-side is that
there are obscure (and hard-to-encounter) bugs, related to people
switching off RTTI compile-time switches in the c++ kdelibs build of
KHTML (that screws up absolutely critical functionality needed by the
python-to-c++ bindings generator)

http://code.google.com/p/pywebkitgtk/issues/detail?id=13 - you need a
patched version of webkit as well, for this to work.

so - it looks like python-hulahop, which depends on python-xpdom, is
the only real "stable" way to do declarative-style DOM manipulation
using python.

hence the reasons why i'm jumping up and down about it, because it's
so damn valuable and so few people know what hulahop is, or that it
even exists!

l.

0 new messages