Given a web application which accepts both normal
HTTP requests and XML-RPC requests, it is
reasonable for that program to assume it can create a
cgi.FieldStorage instance in either case. This works
fine in Python 1.5.2 but causes exceptions in Python
2.x.x when using the created FieldStorage. This is due
to the content-type header generated by xmlrpclib.py
('text/xml') being unrecognised in cgi.py, as a result of
which no FieldStorage.list is created.
One solution is to reinstate some code in cgi.py from
the 1.5.2 release, at the end of method __init__, after
removing the current final two lines:
#else:
# self.read_single()
# SP 2002/6/15: The following code is taken
from the Python 1.5.2 version
# of cgi.py, as incoming xmlrpclib requests
otherwise do not cause 'list'
# to be set up correctly.
elif self.outerboundary:
# we're in an inner part, but the content-type
wasn't something we
# understood. default to read_single()
because the resulting
# FieldStorage won't be a mapping (and
doesn't need to be).
self.read_single()
else:
# we're in an outer part, but the content-type
wasn't something we
# understood. we still want the resulting
FieldStorage to be a
# mapping, so parse it as if it were urlencoded
self.read_urlencoded()
|