ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> pyxpcom
pyxpcom
[pyxpcom] Python errors/warnings when quitting during page load
by Ben Morgan other posts by this author
May 24 2009 10:39PM messages near this date
view in the new Beta List Site
[pyxpcom] Handling custom events in python | [pyxpcom] python and xulrunner - how to use
My application has two windows, which both load content from a protocol
handler. Only one of them has python permissions for this example.
I tried making the protocol handler serve up HTML with the following script
tag in the head:
    <script type="application/x-python"> 
from mozutils import doAlert, doQuit
doAlert("Security Violated!!! Aborting.")
doQuit(True)
</script> 

This does quit, but gives logs the following to the console twice:
WARNING:xpcom:Python DOM script error
<type 'exceptions.SystemError'> : NULL object passed to Py_BuildValue

Changing it to doQuit(False) gives an exception, and will close one of my
two windows - the one without python permission (and if I then reload
content in the one which is still there, I can get it to crash):
Traceback (most recent call last):
  File "/afs/
cc.monash.edu.au/users/b/p/bpmor3/bpbibleng/xulrunner/pylib/nsdom/context.py",
line 432, in EvaluateString
    exec co in glob
  File "bpbible://esv/Matthew%202:1", line 15, in <module> 
  File "/afs/cc.monash.edu.au/users/b/p/bpmor3/bpbibleng/pylib/mozutils.py",
line 16, in doQuit
    appStartup.quit(quitSeverity)
  File "<XPCOMObject method 'quit'> ", line 3, in quit
<class 'xpcom.Exception'> : -2147467259 (-2147467259)

doQuit is taken from one of the python xpcom samples:
def doQuit(forceQuit=False):
    appStartup = Components.classes['@
mozilla.org/toolkit/app-startup;1'].getService(Components.interfaces.nsIAppStartup)<http://m
ozilla.org/toolkit/app-startup;1%27%5D.getService%28Components.interfaces.nsIAppStartup%29> 

    # eAttemptQuit will try to close each XUL window, but the XUL window can
cancel the quit
    # process if there is unsaved data. eForceQuit will quit no matter what.
    if forceQuit:
        quitSeverity = Components.interfaces.nsIAppStartup.eForceQuit
     else:
        quitSeverity = Components.interfaces.nsIAppStartup.eAttemptQuit
    appStartup.quit(quitSeverity)

God Bless,
Ben
-------------------------------------------------------------------------------------------
Multitudes, multitudes,
   in the valley of decision!
For the day of the LORD is near
   in the valley of decision.

Giôên 3:14 (ESV)

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved