Jim Gallacher
jpg at jgassociates.ca
Thu Jan 11 20:28:26 EST 2007
Emiliano Moscato wrote: > Hi all! > > I'm getting crazy trying to receive xforms xml data with mod_python + > publisher handler. > In a normal HTML form, the data would be sent as > application/x-www-form-urlencoded, in the XForms world however, this > information is sent as XML formatted data (application/xml). > Up to now I've used cherryPy as web server and I've got my xml data with > cherrypy.threadData.xform. > I've read that PHP receive this in $HTTP_RAW_POST_DATA variable. If I send > the form to a php script all work fine. > But when I try to submit a xforms with method POST to a script managed by > publisher handler I get an error with no log in my apache server error log. > Any help? You'll need to elaborate on the error you are getting, but I think part of the problem is that you are bumping up against part of the internal "magic" of publisher. Publisher automatically creates a FieldStorage instance. Unfortunately FieldStorage assumes that the content-type starts with either "application/x-www-form-urlencoded" or "multipart/". If I had to guess I'd say that you are getting "501 Not Implemented error" as a result. Here are a couple of solutions that you might consider as a workaround: 1. Hack util.FieldStorage to properly handle your content-type. If you do this feel free to submit a patch so FieldStorage can be fixed. ;) 2. Hack publisher to skip the automatic creation of FieldStorage. (Line 424 in publisher.py for mod_python 3.3.0b). You can then use req.read() to read and process the POST'd data within your content handler. 3. Use a PythonFixupHandler before the content handler. In the fixuphandler use req.read() to grab the raw data and adjust the content-type header so that FieldStorage doesn't bomb out. Note that if you want to pass xml field data as parameters to your handler method you'll need to do a bit more work. For example def index(foo="bar"): return "whatever" won't get foo from your xml data. You can likely work around this but you'll need to take a look at the source for FieldStorage and publisher to work out a strategy. I hope this helps. Jim
|