[PyQt] design flaw in python khtml DOM bindings
lkcl
lkcl at lkcl.net
Wed Oct 15 13:58:17 BST 2008
David Boddie wrote:
>
> I don't think it was a problem in PyKDE3. At least, I don't remember
> running
> into any issues with casting - not with the DOM classes anyway. My brother
> wrote some convenience wrappers around the KHTML DOM, so I think I would
> have
> heard something if it had been broken.
>
> Maybe it was broken, but just wasn't an issue.
>
yeah - i don't believe anyone's tried something as ambitious as pyjamas
using pykde3, before. yes i encountered the pykhtml convenience wrappers
(they're great!) i'm doing some extension to it, to complete it into a more
comprehensive wrapper set that i need for pyjamas, and i'm likely also to
_re-port_ dom.py _back_ to the pyjamas-webkit port, because of the
inconvenience of that stupid _stupid_ thing "props" that pygobject offers
ARG :) ok - there already exists a wrapper to make that a dict, but for
some reason it doesn't work.
regarding your comment that there are no issues with casting: there are no
issues with casting ... until you try to do comparisons against nodes, or
you try to add extra variables to a node.
e.g. like this:
def onClick(event):
print "hello"
n = document().createTextNode("hello world")
n.setId("hello_world_id") # or something that sets the attribute
id="hello_world_id"
b = document().getElementsByClassName("body")[0] # khtmlpy syntax.... excuse
me :)
b.appendChild(n)
n.listener_fn = onClick
n.addEvent("onclick", n.listener_fn) # again, see khtmlpy
does this work? errr.... no :)
why doesn't it work?
this is why:
retrieve_n = document().getElementById("hello_world_id")
assert(retrieve_n.innerHTML == n.innerHTML) # yep - this works. same
"node"....
assert(retrieve_n == n) # WARK, WARK! oh dear - n != retrieve_n, even though
it's the same c++ object.
print n.listener_fn # yep - our original pointer has the listener_fn still
in it....
<function onClick...>
print retrieve_n.listener_fn # WARK, WARK! it's a different python
wrapper... around the same c++ object!
hope this clarifies.
l.
--
View this message in context: http://www.nabble.com/design-flaw-in-python-khtml-DOM-bindings-tp19982564p19992946.html
Sent from the PyQt mailing list archive at Nabble.com.
More information about the PyQt
mailing list