Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

get XMLHttpRequest event handling working in MSHTML

git-svn-id: https://pyjamas.svn.sourceforge.net/svnroot/pyjamas/trunk@1108 7a2bd370-bda8-463c-979e-2900ccfb811e
  • Loading branch information...
commit 789a97516574cf7cc12518a38191a1a5bb98c7dd 1 parent d6fe619
lkcl authored
View
17 INSTALL.txt
@@ -13,6 +13,23 @@ are critical to pyjamas. It goes without saying that if you overwrite
the standard python modules with the pyjamas equivalents, you will run into
massive problems. Don't do it.
+Dependencies
+============
+
+For pyjamas javascript compilation, you need python 2 - that's it.
+
+For Pyjamas Desktop, you will need:
+
+* Win32 comtypes, or python-hulahop and python-xpcom, or a patched
+ version of pywebkitgtk and webkit-gobject: see
+ http://github.com/lkcl/webkit/16401.master
+
+ These are for the MSHTML, XULrunner and Webkit ports of Pyjamas
+ Desktop, respectively.
+
+* python-jsonrpc which can be downloaded from http://json-rpc.org
+ if you wish to use JSONRPC.
+
Developer Sandbox Setup
=======================
View
0  examples/jsonrpc/JSONRPCExample.py 100644 → 100755
File mode changed
View
4 library/pyjamas/HTTPRequest.py
@@ -86,7 +86,7 @@ def asyncPostImpl(self, user, pwd, url, postData, handler,
url = uri[:slash+1] + url
print "xmlHttp", user, pwd, url, postData, handler, dir(xmlHttp)
#try :
- if mf.platform == 'webkit':
+ if mf.platform == 'webkit' or mf.platform == 'mshtml':
xmlHttp.open("POST", url, True, '', '')
else:
# EEK! xmlhttprequest.open in xpcom is a miserable bastard.
@@ -99,7 +99,7 @@ def asyncPostImpl(self, user, pwd, url, postData, handler,
# xmlHttp.setRequestHeader("Set-Cookie", c)
# print "setting cookie", c
- if mf.platform == 'webkit':
+ if mf.platform == 'webkit' or mf.platform == 'mshtml':
mf._addXMLHttpRequestEventListener(xmlHttp, "onreadystatechange",
self.onReadyStateChange)
else:
View
29 pyjd/mshtml.py
@@ -26,6 +26,7 @@
if not hasattr(sys, 'frozen'):
GetModule('atl.dll')
GetModule('shdocvw.dll')
+ GetModule('msxml2.dll')
kernel32 = windll.kernel32
user32 = windll.user32
@@ -38,6 +39,7 @@
#from comtypes.client import GetEvents, ShowEvents
import mshtmlevents
from comtypes.gen import SHDocVw
+from comtypes.gen import MSXML2
from comtypes.gen import MSHTML
kernel32 = windll.kernel32
@@ -325,12 +327,20 @@ def getDomWindow(self):
def _addXMLHttpRequestEventListener(self, node, event_name, event_fn):
- return None
- listener = xpcom.server.WrapObject(ContentInvoker(node, event_fn),
- interfaces.nsIDOMEventListener)
- print event_name, listener
- node.addEventListener(event_name, listener, False)
- return listener
+ print "_addXMLHttpRequestEventListener", event_name
+
+ rcvr = mshtmlevents._DispEventReceiver()
+ rcvr.dispmap = {0: event_fn}
+
+ print rcvr
+ rcvr.sender = node
+ print rcvr.sender
+ ifc = rcvr.QueryInterface(IDispatch)
+ print ifc
+ v = VARIANT(ifc)
+ print v
+ setattr(node, event_name, v)
+ return ifc
def addEventListener(self, node, event_name, event_fn):
@@ -368,9 +378,10 @@ def _addWindowEventListener(self, event_name, event_fn):
return event_name # hmmm...
def getXmlHttpRequest(self):
- xml_svc_cls = components.classes[ \
- "@mozilla.org/xmlextras/xmlhttprequest;1"]
- return xml_svc_cls.createInstance(interfaces.nsIXMLHttpRequest)
+ print "getXMLHttpRequest"
+ o = comtypes.client.CreateObject('MSXML2.XMLHTTP.3.0')
+ print "getXMLHttpRequest", o
+ return Dispatch(o)
def getUri(self):
return self.application
View
11 pyjd/mshtmlevents.py
@@ -226,17 +226,20 @@ class _DispEventReceiver(comtypes.COMObject):
# as last parameter?
def IDispatch_Invoke(self, this, memid, riid, lcid, wFlags, pDispParams,
pVarResult, pExcepInfo, puArgErr):
- #print "IDispatch_Invoke", memid, this, riid, lcid, pDispParams
+ print "IDispatch_Invoke", memid, this, riid, lcid, pDispParams
mth = self.dispmap.get(memid, None)
if mth is None:
return S_OK
dp = pDispParams[0]
- #print "num args", dp.cArgs
+ print "num args", dp.cArgs
# DISPPARAMS contains the arguments in reverse order
args = [dp.rgvarg[i].value for i in range(dp.cArgs)]
- #print "Event", self, memid, mth, args
+ print "Event", self, memid, mth, args
+ event = None
+ if len(args) > 0:
+ event = wrap(args[0])
try:
- result = mth(self.sender, wrap(args[0]), None)
+ result = mth(self.sender, event, None)
except:
sys.stderr.write( traceback.print_exc() )
sys.stderr.flush()
Please sign in to comment.
Something went wrong with that request. Please try again.