Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
    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):
            return True
        else:
Ejemplo n.º 5
0
            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
    if callable(path):
        xmlrpcdispatcher.register_function(path, name)
        continue
Ejemplo n.º 6
0
        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
    if callable(path):
        xmlrpcdispatcher.register_function(path, name)
Ejemplo n.º 7
0
    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>')

    response['Content-length'] = str(len(response.content))
    return response

def multiply(a, b):
    """
    Multiplication is fun!