Flash XMLRPC clients for Zope ....
I saw an enquiry a while back about Flash XML-RPC clients. After some spelunking I can add my 2 eurocents to the situation ... unfortunately not good news. The Flash player (version 42, AFAIK the newest) now claims to allow the setting of the Content-type, necessary for getting Zope to agree that this is xmlrpc, but still appears to have a bug where it appends a few garbage characters after the desired value. Zope checks for exact content type of text/xml and therefore fails to recognise the request. I haven't found a way to persuade the flash player not to do this although one may exist. I have patched my Zoep to check only the first 8 characters, this then works OK, but is ugly, and incorrect! I'll report the assumed bug to M'media and see what they have to say! regards, Nigel.
Hi Nigel, I got so frustrated with Flash Player I just cooked up my own way. The version I was using had no way to set content type! I ended up with a couple of external methods and a Python Script to use them. There is/was also a problem with the Windows version of FlashPlayer. The sendAndLoad command is supposed to do a POST, but it sends a "GET" command, and then "POST"s anyway. ;-( So I commented out the meth != GET below and unconditionally seek/read stdin. I posted a detailed bug report to MM, but got no response. Anyway.. thanks for the update. I wonder if they'll ever get it right? ;-( -steve On Monday, August 6, 2001, at 12:18 AM, Nigel Head wrote:
I saw an enquiry a while back about Flash XML-RPC clients. After some spelunking I can add my 2 eurocents to the situation ... unfortunately not good news.
The Flash player (version 42, AFAIK the newest) now claims to allow the setting of the Content-type, necessary for getting Zope to agree that this is xmlrpc, but still appears to have a bug where it appends a few garbage characters after the desired value. Zope checks for exact content type of text/xml and therefore fails to recognise the request. I haven't found a way to persuade the flash player not to do this although one may exist.
I have patched my Zoep to check only the first 8 characters, this then works OK, but is ugly, and incorrect!
I'll report the assumed bug to M'media and see what they have to say!
regards,
Nigel.
External Methods: rawInput: def getRawInput(self, REQUEST): meth = REQUEST.environ.get('REQUEST_METHOD','GET') if 1: # meth != 'GET': # # Flash has a broken .sendAndLoad() method on Windows.. so we need to # force a "POST" response rather than handle "GET" # REQUEST.stdin.seek(0) result = REQUEST.stdin.read() else: result = REQUEST.environ.get('QUERY_STRING','') return result handleXML: def getRawInput(self, REQUEST): meth = REQUEST.environ.get('REQUEST_METHOD','GET') if meth != 'GETfoo': # # Flash has a broken .sendAndLoad() method on Windows.. so we need to # force a "POST" response rather than handle "GET" # REQUEST.stdin.seek(0) result = REQUEST.stdin.read() else: result = REQUEST.environ.get('QUERY_STRING','') return result Finally.. here is the PythonScript to use getRawInput and handleXML: import string REQUEST=context.REQUEST rawInput = context.getRawInput(REQUEST) if len(rawInput): try: xmlDict = context.handleXML(rawInput) except: xmlDict = {} else: xmlDict = {} -steve
Oops... sorry.. somehow handleXML got nipped.. this might be handy for someone else wanting simple xml converted to dicts for easy python processing.. On Monday, August 6, 2001, at 03:43 AM, Steve Spicklemire wrote:
Hi Nigel,
On Monday, August 6, 2001, at 12:18 AM, Nigel Head wrote:
I saw an enquiry a while back about Flash XML-RPC clients. After some spelunking I can add my 2 eurocents to the situation ... unfortunately not good news.
handleXML: # # Handle XML input from Flash. # Needs ParsedXML product installed. # if __name__=="__main__": """ For in 'IDE' testing.. """ import sys sys.path.append('/usr/local/etc/Zope2b/lib/python') import ZODB from Products.ParsedXML.DOM import ExpatBuilder try: from cStringIO import StringIO except ImportError: from StringIO import StringIO def handleXML(xmlString, debug=0): return toDict(DOMParseString( None, xmlString), debug=debug) def DOMParseString(self, xml): file = StringIO(xml) return ExpatBuilder.parse(file) def toDict( xmlThing, currDict=None, debug=0 ): if currDict is None: currDict = {} if hasattr(xmlThing,'data'): currDict['data'] = xmlThing.data if hasattr(xmlThing, '_attributes'): if debug: print "checking attributes:", xmlThing._attributes for attr in xmlThing._attributes: if currDict.has_key(attr[1]): oldVal = currDict[attr[1]] if type(oldVal)==type(''): currDict[attr[1]]=[oldVal, attr[4]] else: oldVal.append(attr[4]) else: currDict[attr[1]] = attr[4] if hasattr(xmlThing, '_children'): for subThing in xmlThing._children: newDict = toDict(subThing) if hasattr(subThing, 'data'): currDict['data'] = subThing.data elif hasattr(subThing, 'nodeName'): if currDict.has_key(subThing.nodeName): oldVal=currDict[subThing.nodeName] if type(oldVal)==type({}): currDict[subThing.nodeName]=[oldVal, newDict] else: oldVal.append(newDict) else: currDict[subThing.nodeName] = newDict return currDict theXML = """<?xml version = "1.0"?> <CD title="2 Against Nature"> <track title = "gaslighting abbie"/> <track title = "what a shame about me"/> <track title = "two against nature"/> <track title = "janie runaway"/> <track title = "almost gothic"/> <track title = "jack of speed"/> <track title = "cousin dupree"/> <track title = "negative girl"/> <track title = "west of hollywood"/> <relatedItems artist = "Steely Dan"/> <relatedItems artist = "Walter Becker"/> <relatedItems artist = "Donald Fagen"/> </CD> """ if __name__=="__main__": #print handleXML('<querySources level="/my/favorite/place"/>') print handleXML(theXML, debug=1)
participants (2)
-
Nigel Head -
Steve Spicklemire