Commit 63f78ddc authored by Jim Fulton's avatar Jim Fulton

added hooks for XML-RPC

parent 74a3d213
......@@ -82,7 +82,7 @@
# attributions are listed in the accompanying credits file.
#
##############################################################################
__version__='$Revision: 1.3 $'[11:-2]
__version__='$Revision: 1.4 $'[11:-2]
import regex, sys, os
from string import lower, atoi, rfind, split, strip, join, upper, find
......@@ -92,7 +92,7 @@ from cgi import FieldStorage
from urllib import quote, unquote
from Converters import type_converters
from maybe_lock import allocate_lock
xmlrpc=None # Placeholder for module that we'll import if we have to.
isCGI_NAME = {
'SERVER_SOFTWARE' : 1,
......@@ -167,16 +167,20 @@ class HTTPRequest(BaseRequest):
other variables, form data, and then cookies.
"""
_hacked_path=None
args=()
def __init__(self, stdin, environ, response, clean=0):
# Avoid the overhead of scrubbing the environment in the
# case of request cloning for traversal purposes. If the
# clean flag is set, we know we can use the passed in
# environ dict directly.
if not clean: environ=sane_environment(environ)
method=environ.get('REQUEST_METHOD','GET')
if environ.get('REQUEST_METHOD','GET') != 'GET': fp=stdin
else: fp=None
if method != 'GET': fp=stdin
else: fp=None
if environ.has_key('HTTP_AUTHORIZATION'):
self._auth=environ['HTTP_AUTHORIZATION']
......@@ -188,7 +192,17 @@ class HTTPRequest(BaseRequest):
meth=None
fs=FieldStorage(fp=fp,environ=environ,keep_blank_values=1)
if not hasattr(fs,'list') or fs.list is None:
form['BODY']=fs.value
# Hm, maybe it's an XML-RPC
if (fs.headers.has_key('content-type') and
fs.headers['content-type'] == 'text/xml' and
method == 'POST'):
# Ye haaa, XML-RPC!
global xmlrpc
if xmlrpc is None: import xmlrpc
meth, self.args = xmlrpc.parse_input(fs.value)
response=xmlrpc.response(response)
else:
form['BODY']=fs.value
else:
fslist=fs.list
tuple_items={}
......
......@@ -84,8 +84,8 @@
##############################################################################
__doc__="""Python Object Publisher -- Publish Python objects on web servers
$Id: Publish.py,v 1.126 1999/03/10 00:15:51 klm Exp $"""
__version__='$Revision: 1.126 $'[11:-2]
$Id: Publish.py,v 1.127 1999/03/18 22:36:23 jim Exp $"""
__version__='$Revision: 1.127 $'[11:-2]
import sys, os
from string import lower, atoi, rfind, strip
......@@ -154,7 +154,7 @@ def publish(request, module_name, after_list, debug=0,
(request_get('AUTHENTICATION_PATH'), auth_user))+info
transaction.note(info)
result=mapply(object,(),request,
result=mapply(object, request.args, request,
call_object,1,
missing_name,
dont_publish_class,
......
"""Skeleton XML-RPC support module
"""
import HTTPResponse
def parse_input(data):
"""Parse input data and return a method path and argument tuple
The data is a string (but maybe it should be a file, oh well,
we'll come back to this if necessary.
"""
#
# For example, with the input:
#
# <?xml version="1.0"?>
# <methodCall>
# <methodName>examples.getStateName</methodName>
# <params>
# <param>
# <value><i4>41</i4></value>
# </param>
# </params>
# </methodCall>
#
# the function should return:
#
# ('examples.getStateName', (41,))
return '', ()
def response(anHTTPResponse):
"""Return a valid ZPublisher response object
Use data already gathered by the existing response.
The new response will replace the existing response.
"""
# As a first cut, lets just clone the response and
# put all of the logic in our refined response class below.
r=Response()
r.__dict__.update(anHTTPResponse.__dict__)
return r
########################################################################
# Possible implementation helpers:
class Response(HTTPResponse.HTTPResponse):
"""Customized HTTPResponse that handles XML-RPC-specific details
I'm just guessing here. XML-RPC wants all errors to be converted
to XML and returned with an 200 OK status.
You'll probably need to override a bunch of the error
handling logic.
"""
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment