def system_listMethods(self): """ Gets a list of the methods supported by the server. :returns: ['method name', ...] :rtype: list """ return SimpleXMLRPCDispatcher.system_listMethods(self)
def rpc_handler(request): """ the actual handler: if you setup your urls.py properly, all calls to the xml-rpc service should be routed through here. If post data is defined, it assumes it's XML-RPC and tries to process as such Empty post assumes you're viewing from a browser and tells you about the service. """ #moving this here to see if it will fix the thread leaks dispatcher = SimpleXMLRPCDispatcher(allow_none=False, encoding=None) # Python 2.5 if len(request.POST): dispatcher.register_function(_updateStatus, 'updateStatus') dispatcher.register_function(_setSceneError, 'setSceneError') dispatcher.register_function(_set_scene_unavailable, 'setSceneUnavailable') dispatcher.register_function(_markSceneComplete, 'markSceneComplete') dispatcher.register_function(_getConfiguration, 'getConfiguration') dispatcher.register_function(_getScenesToProcess, 'getScenesToProcess') dispatcher.register_function(_getScenesToPurge, 'getScenesToPurge') dispatcher.register_function(_getSceneInputPath, 'getSceneInputPath') dispatcher.register_function(_getDataSourceCredentials, 'getDataSourceCredentials') #if our leak isn't fixed, try checking to see if we need to close the response here. response = HttpResponse(mimetype="application/xml") response.write(dispatcher._marshaled_dispatch(request.raw_post_data)) else: response = HttpResponse() response.write("<b>This is an XML-RPC Service.</b><br>") response.write("You need to invoke it using an XML-RPC Client!<br>") response.write("The following methods are available:<ul>") methods = dispatcher.system_listMethods() for method in methods: # right now, my version of SimpleXMLRPCDispatcher always # returns "signatures not supported"... :( # but, in an ideal world it will tell users what args are expected sig = dispatcher.system_methodSignature(method) # this just reads your docblock, so fill it in! help = dispatcher.system_methodHelp(method) response.write("<li><b>%s</b>: [%s] %s" % (method, sig, help)) response.write("</ul>") response.write('<a href="http://www.djangoproject.com/"> <img src="http://media.djangoproject.com/img/badges/djangomade124x25_grey.gif" border="0" alt="Made with Django." title="Made with Django."></a>') response['Content-length'] = str(len(response.content)) return response
class ServerGateway(object): def __init__(self, prefix): self.prefix = prefix try: # Python 2.4 self.dispatcher = SimpleXMLRPCDispatcher() except TypeError: # Python 2.5 self.dispatcher = SimpleXMLRPCDispatcher(allow_none=False, encoding=None) def add_function(self, name, func): self.dispatcher.register_function(func, ".".join([self.prefix, name])) def connect( self, func=None, name=None): def _connector(func): self.add_function(not name and func.__name__ or name, func) return func if not func: return _connector else: _connector(func) return func def __call__(self, request, *args, **kwargs): if kwargs: raise RuntimeError("Xmlrpc server gateway cannot handle key variable argumets") def custom_dispatch(method, params): return self.dispatcher._dispatch(method, params + tuple(args)) response = HttpResponse() if len(request.POST): response.write(self.dispatcher._marshaled_dispatch(request.raw_post_data, custom_dispatch)) else: methods = self.dispatcher.system_listMethods() response['Content-Type'] = 'text/plain' for method in methods: # __doc__ help = self.dispatcher.system_methodHelp(method) response.write("%s:\n %s\n\n" % (method, help)) response['Content-Length'] = str(len(response.content)) return response
def rpc_handler(request): """ the actual handler: if you setup your urls.py properly, all calls to the xml-rpc service should be routed through here. If post data is defined, it assumes it's XML-RPC and tries to process as such. Empty post assumes you're viewing from a browser and tells you about the service. """ d = SimpleXMLRPCDispatcher(allow_none=True, encoding=None) if len(request.body): d.register_function(_update_status, 'update_status') d.register_function(_set_product_error, 'set_scene_error') d.register_function(_set_product_unavailable, 'set_scene_unavailable') d.register_function(_mark_product_complete, 'mark_scene_complete') d.register_function(_handle_orders, 'handle_orders') d.register_function(_queue_products, 'queue_products') d.register_function(_get_configuration, 'get_configuration') d.register_function(_get_products_to_process, 'get_scenes_to_process') d.register_function(_get_data_points, 'get_data_points') response = HttpResponse(mimetype="application/xml") response.write(d._marshaled_dispatch(request.body)) else: response = HttpResponse() response.write("<b>This is an XML-RPC Service.</b><br>") response.write("You need to invoke it using an XML-RPC Client!<br>") response.write("The following methods are available:<ul>") methods = d.system_listMethods() for method in methods: sig = d.system_methodSignature(method) # this just reads your docblock, so fill it in! help_msg = d.system_methodHelp(method) response.write("<li><b>%s</b>: [%s] %s" % (method, sig, help_msg)) response.write("</ul>") response['Content-length'] = str(len(response.content)) return response
class RpcHandler: def __init__(self): self.__dispatcher = SimpleXMLRPCDispatcher(allow_none=False, encoding=None) def dispatcher(self): return self.__dispatcher def rpc_handler(self,request): """ the actual handler: if you setup your urls.py properly, all calls to the xml-rpc service should be routed through here. If post data is defined, it assumes it's XML-RPC and tries to process as such Empty post assumes you're viewing from a browser and tells you about the service. """ if len(request.POST): response = HttpResponse(mimetype="application/xml") response.write(self.__dispatcher._marshaled_dispatch(request.raw_post_data)) else: response = HttpResponse() response.write("<b>This is an XML-RPC Service.</b><br>") response.write("You need to invoke it using an XML-RPC Client!<br>") response.write("The following methods are available:<ul>") methods = self.__dispatcher.system_listMethods() for method in methods: # right now, my version of SimpleXMLRPCDispatcher always # returns "signatures not supported"... :( # but, in an ideal world it will tell users what args are expected sig = self.__dispatcher.system_methodSignature(method) # this just reads your docblock, so fill it in! help = self.__dispatcher.system_methodHelp(method) response.write("<li><b>%s</b>: [%s] %s" % (method, sig, help)) response.write("</ul>") # response['Content-length'] = str(len(response.content)) return response
#print response pass return response except Exception, e: return HttpResponseServerError() else: # response.write("<b>This is an XML-RPC Service.</b><br>") # response.write("You need to invoke it using an XML-RPC Client!<br>") # response.write("The following methods are available:<ul>") # methods = xmlrpcdispatcher.system_listMethods() # for method in methods: # help = xmlrpcdispatcher.system_methodHelp(method) # response.write("<li><b>%s</b>:<br/><i>%s</i>" % (method, help)) # response.write("</ul>") # return response methods = xmlrpcdispatcher.system_listMethods() resp=[] for method in methods: help = xmlrpcdispatcher.system_methodHelp(method) resp.append({'name': method, 'help': help, 'params': ''}) return render_to_response('rpcdoc.html',{'methods': resp}) #return render_to_response(settings.XMLRPC_GET_TEMPLATE) # Load up any methods that have been registered with the server in settings for path, name in settings.XMLRPC_METHODS: # if "path" is actually a function, just add it without fuss if callable(path): xmlrpcdispatcher.register_function(path, name) continue # Otherwise we try and find something that we can call
""" Escuchador actual: mediante el urls.py, todas las llamadas del servicio xml-rpc pueden ser enrutadas por aqui. """ response = HttpResponse() if request.POST: try: response.write(dispatcher._marshaled_dispatch(request.raw_post_data)) except Exception, e: return HttpResponseServerError() else: #TODO Realizar descripcion del servicio response.write("<b>Servicio XML-RPC ofrecido por el sistema web GME.</b><br>") response.write("Metodos disponibles mediante XML-RPC!<br><ul>") methods = dispatcher.system_listMethods() for method in methods: sig = dispatcher.system_methodSignature(method) help = dispatcher.system_methodHelp(method) #response.write("<li><b>%s</b>: [%s] %s" % (method, help)) response.write("<li><b>%s</b>: %s</li>" % (method,help)) response.write("</ul>") response.write('<a href="http://www.djangoproject.com/"> <img src="http://media.djangoproject.com/img/badges/djangomade124x25_grey.gif" border="0" alt="Made with Django." title="Made with Django."></a>') response['Content-length'] = str(len(response.content)) return response def verificar_password(usuario, password): '''Verifica la autenticidad del usuario en el sistema''' try: usuario = User.objects.get(username=usuario) if usuario.check_password(password):
if settings.DEBUG: print request.raw_post_data try: response = HttpResponse(content_type='text/xml') response.write( xmlrpcdispatcher._marshaled_dispatch(request.raw_post_data)) #if settings.DEBUG: print response return response except Exception, e: return HttpResponseServerError() else: response = HttpResponse() response.write("<b>This is an XML-RPC Service.</b><br/>") response.write("You need to invoke it using an XML-RPC Client!<br/>") response.write("The following methods are available:<ul>") methods = xmlrpcdispatcher.system_listMethods() for method in methods: sig = xmlrpcdispatcher.system_methodSignature(method) #help = xmlrpcdispatcher.system_methodHelp(method) # does not work because appengine running in sandboxed python help = '[help not supported] ' response.write("<li><b>%s</b>: [%s] %s</li>" % (method, sig, help)) response.write("</ul>") #response.write('<a href="http://www.djangoproject.com/"> <img src="http://media.djangoproject.com/img/badges/djangomade124x25_grey.gif" border="0" alt="Made with Django." title="Made with Django."></a>') #return render_to_response(settings.XMLRPC_GET_TEMPLATE) response['Content-length'] = str(len(response.content)) return response # Load up any methods that have been registered with the server in settings for path, name in settings.XMLRPC_METHODS: # if "path" is actually a function, just add it without fuss
the actual handler: if you setup your urls.py properly, all calls to the xml-rpc service should be routed through here. If post data is defined, it assumes it's XML-RPC and tries to process as such Empty post assumes you're viewing from a browser and tells you about the service. """ if len(request.POST): response = HttpResponse(mimetype="application/xml") response.write(dispatcher._marshaled_dispatch(request.raw_post_data)) else: response = HttpResponse() response.write("<b>This is an XML-RPC Service.</b><br>") response.write("You need to invoke it using an XML-RPC Client!<br>") response.write("The following methods are available:<ul>") methods = dispatcher.system_listMethods() for method in methods: # right now, my version of SimpleXMLRPCDispatcher always # returns "signatures not supported"... :( # but, in an ideal world it will tell users what args are expected sig = dispatcher.system_methodSignature(method) # this just reads your docblock, so fill it in! help = dispatcher.system_methodHelp(method) response.write("<li><b>%s</b>: [%s] %s" % (method, sig, help)) response.write("</ul>") response.write('<a href="http://www.djangoproject.com/"> <img src="http://media.djangoproject.com/img/badges/djangomade124x25_grey.gif" border="0" alt="Made with Django." title="Made with Django."></a>')