[PyQt] design flaw in python khtml DOM bindings
Luke Kenneth Casson Leighton
lkcl at lkcl.net
Tue Oct 14 22:21:12 BST 2008
folks, hi,
thanks to some kind people on the kde-dev mailing list i'm posting
here to describe an important design issue which makes the python
khtml.DOM bindings completely unusable - for serious projects - unless
it's fixed.
the issue is that the wrapper objects aren't unique [don't return the
same python object for a given DOM c++ object], due to the underlying
c++ objects being typecast down to "Node*" (or Element*), and the use
of the khtml.DOM.* "casting" functions being inadequate for the job.
the issue is described in detail here:
http://lists.kde.org/?l=kde-devel&m=122398222122025&w=2
the bugreport is here:
https://bugs.kde.org/show_bug.cgi?id=172740
an example of the code which gets it _right_ - in webkit - is here:
http://github.com/lkcl/webkit/tree/16401.master/WebCore/bindings/gdom
note the quite extensive html element wrapper factory, the extensive
GDOMBindings.cpp which basically cover EVERY single object and i mean
ALL of them, with a wrapper that ALWAYS goes via the Hashmap before
returning the object.
in this way, it is absolutely absolutely cast-iron-guaranteed that,
even when you call KHTMLPart.document.getElementById("body_id") you
WILL get a khtml.DOM.HTMLBodyElement back - NOT a khtml.DOM.Node.
i cannot express enough how much _not_ fixing this makes khtml
completely unusable.
i have got quite a long way already in porting pyjamas to khtml:
http://github.com/lkcl/pyjamas-desktop/tree/master/pyjamas-khtml
the port of pyjamas to khtml is in honour of khtml being the
grand-daddy of webkit :) so, it'd be nice if it worked! but, being
unable to do "if node1 == node2" because there's no one-for-one
mapping of c++ to python wrapper objects is a _complete_ show-stopper.
l.
More information about the PyQt
mailing list