[Pyxpcomext] Display and Rendering Question

Peter Rust peter at cornerstonenw.com
Thu Feb 25 11:44:37 PST 2010


Ah, thanks Todd!
 
I was wondering why I couldn't find an XPCOM interface for Browser.
 
An alternative to writing the Javascript XPCOM wrapper would be to write the
python in PyDOM instead of PyXPCOM, correct?
 
And haven't you mentioned the possibility of 3rd option, a python
implementation of  <https://developer.mozilla.org/en/NPObject> NPObject that
would overcome the limitations of both pyDOM and pyXPCOM, allowing
interaction with both Javascript and the DOM?
 
-- peter
 
-----Original Message-----
From: pyxpcomext-bounces at mozdev.org [mailto:pyxpcomext-bounces at mozdev.org]
On Behalf Of Todd Whiteman
Sent: Thursday, February 25, 2010 10:35 AM
To: Nathan Hamiel
Cc: pyxpcomext at mozdev.org
Subject: Re: [Pyxpcomext] Display and Rendering Question
 
On 10-02-25 09:38 AM, Nathan Hamiel wrote:
> I have a couple of questions about the display and rendering of HTML 
> using XUL with Python. For example in my XULrunner application, I want 
> to construct a request using httplib or httplib2 and display the 
> return data in both HTML source as well as rendered HTML.
> 
> So I would have something like so:
> 
> urlval = "http://python.org"
> handler = httplib2.Http()
> resp, content = handler.request(urlval, "GET")
> 
> I have some tabpanels set up with vbox's on them. What I would like to 
> do after the request for this content is made is take the content 
> value, which contains the HTML of the return response, and on one 
> panel display the HTML source (preferably syntax highlighted) and on 
> other panel render the HTML. It shouldn't matter how the HTML is 
> retrieved though since at some point it may be pulled from something 
> such as a SQLite database or other storage mechanism.
> 
> I am not sure of the best way to go about this. If there are any 
> examples or documentation anyone can point me to, it would be greatly 
> appreciated. Sorry if the answer is painfully obvious and there is 
> something I am just not getting.
> 
> I have even tried to use the browser object by instantiating it like so:
> 
> In my XUL file I have:
> <browser id="browser" src="about:blank" flex="1" />
> 
> In my .py file I have:
> browser = document.getElementById("browser")
> 
> However, when trying to use this an to say reload an error like so 
> happens:
> 
> XPCOM component '<unknown>' has no attribute 'reload'
> 
> Anyway, I am stumped and I figured I would ask for help. Please let me 
> know if I need to provide more detail and I will gladly do so. Thanks 
> in advance.
> 
 
It's because <browser> is a XBL element and XBL elements are generally 
not exposed through XPCOM. You can check the implements section of:
http://mxr.mozilla.org/mozilla1.9.1/source/toolkit/content/widgets/browser.x
ml#51
 
that means these XBL properties/methods like "reload", "goBack", 
"autoscrollEnabled" are not exposed to XPCOM, so if you try to use them 
via XPCOM you'll get an attribute error like the one above.
 
You'll need to use JavaScript to obtain access to these methods. For 
Python/XPCOM, you'd need to write a JavaScript XPCOM wrapper that 
exposes the browser functionality you need, so Python would call your JS 
XPCOM browser component and then the JS component would call the XBL 
browser methods.
 
Cheers,
Todd
 
 
_______________________________________________
Pyxpcomext mailing list
Pyxpcomext at mozdev.org
https://www.mozdev.org/mailman/listinfo/pyxpcomext
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mozdev.org/pipermail/pyxpcomext/attachments/20100225/fcce8b07/attachment-0001.html>


More information about the Pyxpcomext mailing list