本文整理汇总了Python中SimpleXMLRPCServer.SimpleXMLRPCDispatcher.register_multicall_functions方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleXMLRPCDispatcher.register_multicall_functions方法的具体用法?Python SimpleXMLRPCDispatcher.register_multicall_functions怎么用?Python SimpleXMLRPCDispatcher.register_multicall_functions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleXMLRPCServer.SimpleXMLRPCDispatcher
的用法示例。
在下文中一共展示了SimpleXMLRPCDispatcher.register_multicall_functions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: XMLRPCDispatcher
# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import register_multicall_functions [as 别名]
class XMLRPCDispatcher(Resource):
'''A Resource that knows how to host an XMLRPCObject and serve it'''
def __init__(self, application, request, response, session, instance=None, methods=[], allow_none=True, encoding=None):
'''initializes this dispatcher which can handle XMLRPC requests.'''
if not instance: raise ValueError("You must pass in a non-null object which we will serve")
super(XMLRPCDispatcher, self).__init__(application, request, response, session)
self.dispatcher = SimpleXMLRPCDispatcher(allow_none=allow_none, encoding=encoding)
self.dispatcher.register_instance(instance)
for method in methods:
self.dispatcher.register_function(method)
self.dispatcher.register_introspection_functions()
self.dispatcher.register_multicall_functions()
@POST
@Route("/{path:.*}")
def post(self, path):
'''
Attempts to process all posts as XMLRPC Requests which are then
dispatched to the XMLRPCObject. Most of the code was taken from
SimpleXMLRPCServer with modifications to make it compatible with
Gates
'''
try:
data = self.request.body
response = self.dispatcher._marshaled_dispatch(
data, getattr(self.dispatcher, '_dispatch', None)
)
except Exception as e: # This should only happen if the module is buggy
# internal error, report as Internal HTTP Server error
traceback.print_exc(e)
abort(500, "XMLRPC Application Error! You shouldn't be seeing this. We're sorry.")
else:
# We got a valid XML RPC response
self.response.type = "text/xml"
self.response.write(response)
示例2: SimpleXMLRPCDispatcher
# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import register_multicall_functions [as 别名]
# Sean Myers <[email protected]>
# Copyright 2008 American Research Institute, Inc.
from SimpleXMLRPCServer import SimpleXMLRPCDispatcher
from django.http import HttpResponse
from pr_services.rpc.service import ServiceManagers
import facade
import settings
import sys
if sys.version_info[:2] == (2, 4):
dispatcher = SimpleXMLRPCDispatcher()
elif sys.version_info[:2] >= (2, 5):
dispatcher = SimpleXMLRPCDispatcher(allow_none = True, encoding = 'utf-8')
dispatcher.register_introspection_functions()
dispatcher.register_multicall_functions()
def gateway(request):
response = HttpResponse()
if len(request.POST):
response = HttpResponse(mimetype="application/xml") # Cleaner to reinstantiate than to add seemingly useless else clause
response.write(dispatcher._marshaled_dispatch(request.raw_post_data))
elif settings.DEBUG:
response.write("<b>This is an XML-RPC Service.</b><br>")
response.write("The following methods are available:<ul>")
methods = dispatcher.system_listMethods()
for method in methods:
help = dispatcher.system_methodHelp(method)
response.write("<li><b>%s</b>: <pre>%s</pre>" % (method, help))
response.write("</ul>")