Re: How to call WebKit.DOMDocument.evaluate function in python



Hi,

On Mon, Jul 1, 2013 at 11:48 PM, Niranjan Rao <nhrdls gmail com> wrote:

I need to perform some DOM operations once the document is loaded. Webkit
DOMDocument provides evaluate method which can allow me to reach to element
using xpath,  if it works. The parameter DOMXPathResult of the evaluate
method has annotations declared in such a way that null/None value in
python can not be used.  However null value in this case is legal and
accepted.


It looks like the introspection bindings are missing (allow-none) for the
parameter. The bindings seem to be generated by a perl script and a quick
web search revieled a related problem here:
https://bugs.webkit.org/show_bug.cgi?id=42115

You should probably log a bug against WebKit Gtk to get the annotation
fixed. Also, have you tried creating an empty WebKit.DOMXPathResult and
passing that?
res = WebKit.DOMXPathResult()

Is there any way to get underlying gobject pointer from python so that I
can use ctypes and try to call function directly. So far my attempts have
resulted in coredump as webkit is asserting on various values I am sending
to it.


Later versions of PyGObject give access to the internal GObject pointer
through the "__gpointer__" attribute on wrapped objects. But it is unclear
if this would be useful in ctypes because it returns a PyCapsule. This
attribute is used internally for some parts of PyGObject. However, we
cannot support this officially as it is an implementation detail, so use at
your own risk.

You should also be able to create a small C extension to Python which wraps
the function up for you.

-Simon


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