当前位置: 首页>>代码示例>>Python>>正文


Python SimpleXMLRPCDispatcher.register_function方法代码示例

本文整理汇总了Python中SimpleXMLRPCServer.SimpleXMLRPCDispatcher.register_function方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleXMLRPCDispatcher.register_function方法的具体用法?Python SimpleXMLRPCDispatcher.register_function怎么用?Python SimpleXMLRPCDispatcher.register_function使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleXMLRPCServer.SimpleXMLRPCDispatcher的用法示例。


在下文中一共展示了SimpleXMLRPCDispatcher.register_function方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import register_function [as 别名]
    def post(self, request):
        dispatcher = SimpleXMLRPCDispatcher(allow_none=False, encoding=None)
        dispatcher.register_function(partial(self.ping, request), 'pingback:ping')

        response = HttpResponse(mimetype="application/xml")
        response.write(dispatcher._marshaled_dispatch(request.raw_post_data))
        return response
开发者ID:graingert,项目名称:humfrey,代码行数:9,代码来源:views.py

示例2: WSGIXMLRPCApplication

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import register_function [as 别名]
class WSGIXMLRPCApplication(object):
    """Application to handle requests to the XMLRPC service"""

    def __init__(self, instance=None, methods=[]):
        """Create windmill xmlrpc dispatcher"""
        self.dispatcher = SimpleXMLRPCDispatcher(allow_none=True,
                                                 encoding=None)
        if instance is not None:
            self.dispatcher.register_instance(instance)
        for method in methods:
            self.dispatcher.register_function(method)
        self.dispatcher.register_introspection_functions()

    def handler(self, environ, start_response):
        """XMLRPC service for windmill browser core to communicate with"""
        if environ['REQUEST_METHOD'] == 'POST':
            return self.handle_POST(environ, start_response)
        else:
            start_response("400 Bad request", [('Content-Type', 'text/plain')])
            return ['']

    def handle_POST(self, environ, start_response):
        """Handles the HTTP POST request.

        Attempts to interpret all HTTP POST requests as XML-RPC calls,
        which are forwarded to the server's _dispatch method for handling.

        Most code taken from SimpleXMLRPCServer with modifications for wsgi and
        my custom dispatcher.
        """
        try:
            # Get arguments by reading body of request.
            # We read this in chunks to avoid straining

            length = int(environ['CONTENT_LENGTH'])
            data = environ['wsgi.input'].read(length)

            # In previous versions of SimpleXMLRPCServer, _dispatch
            # could be overridden in this class, instead of in
            # SimpleXMLRPCDispatcher. To maintain backwards compatibility,
            # check to see if a subclass implements _dispatch and
            # using that method if present.
            response = self.dispatcher._marshaled_dispatch(
                    data, getattr(self.dispatcher, '_dispatch', None)
                )
            response += '\n'
        except:  # This should only happen if the module is buggy
            # internal error, report as HTTP server error
            start_response("500 Server error", [('Content-Type',
                                                 'text/plain')])
            return []
        else:
            # got a valid XML RPC response
            start_response("200 OK", [('Content-Type', 'text/xml'),
                                      ('Content-Length', str(len(response)),)])
            return [response]

    def __call__(self, environ, start_response):
      return self.handler(environ, start_response)
开发者ID:Seb182,项目名称:cloudooo,代码行数:61,代码来源:wsgixmlrpcapplication.py

示例3: handler

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import register_function [as 别名]
def handler(request, response, methods):
    response.session_id = None  # no sessions for xmlrpc
    dispatcher = SimpleXMLRPCDispatcher(allow_none=True, encoding=None)
    for method in methods:
        dispatcher.register_function(method)
    dispatcher.register_introspection_functions()
    response.headers['Content-Type'] = 'text/xml'
    dispatch = getattr(dispatcher, '_dispatch', None)
    return dispatcher._marshaled_dispatch(request.body.read(), dispatch)
开发者ID:AftabiPhone,项目名称:Inventariofmo,代码行数:11,代码来源:xmlrpc.py

示例4: get_handler

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import register_function [as 别名]
def get_handler(methodlist):
    dispatcher = SimpleXMLRPCDispatcher(False, None)
    for method in web.group(methodlist, 2):
        dispatcher.register_function(method[1], method[0])
    class rpc:
        def GET(self):
            web.header('Content-Type', 'text/html')
            print get_doc(dispatcher)

        def POST(self):
            response = dispatcher._marshaled_dispatch(web.webapi.data())
            web.header('Content-Type', 'text/xml')
            web.header('Content-length', str(len(response)))
            print response
    return rpc
开发者ID:adambregenzer,项目名称:hydra,代码行数:17,代码来源:webxml.py

示例5: ServerGateway

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import register_function [as 别名]
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
开发者ID:pombredanne,项目名称:turbion,代码行数:47,代码来源:xmlrpc.py

示例6: XMLRPCApplication

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import register_function [as 别名]
class XMLRPCApplication(RestApplication):
    """Application to handle requests to the XMLRPC service"""

    def __init__(self, instance=None, methods=[]):
        """Create windmill xmlrpc dispatcher"""
        try:
            self.dispatcher = SimpleXMLRPCDispatcher(allow_none=True, encoding=None)
        except TypeError:
            # python 2.4
            self.dispatcher = SimpleXMLRPCDispatcher()
        if instance is not None:
            self.dispatcher.register_instance(instance)
        for method in methods:
            self.dispatcher.register_function(method)
        self.dispatcher.register_introspection_functions()
        
    def POST(self, request, *path):
        """Handles the HTTP POST request.

        Attempts to interpret all HTTP POST requests as XML-RPC calls,
        which are forwarded to the server's _dispatch method for handling.
        
        Most code taken from SimpleXMLRPCServer with modifications for wsgi and my custom dispatcher.
        """
        
        try:
            data = str(request.body)
            
            # In previous versions of SimpleXMLRPCServer, _dispatch
            # could be overridden in this class, instead of in
            # SimpleXMLRPCDispatcher. To maintain backwards compatibility,
            # check to see if a subclass implements _dispatch and 
            # using that method if present.
            response = self.dispatcher._marshaled_dispatch(
                    data, getattr(self.dispatcher, '_dispatch', None)
                )
            response += '\n'
        except: # This should only happen if the module is buggy
            # internal error, report as HTTP server error
            return Response500()
        else:
            # got a valid XML RPC response
            return XMLResponse(response)
开发者ID:ijs,项目名称:windmill,代码行数:45,代码来源:xmlrpc.py

示例7: XmlRpc

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import register_function [as 别名]
class XmlRpc(object):
    def __init__(self, encoding=None, allow_none=True, use_datetime=0):
        self.__queue = []
        self.__encoding = encoding
        self.__allow_none = allow_none
        self.__use_datetime = use_datetime
        self.__dispatcher = SimpleXMLRPCDispatcher(allow_none=allow_none, encoding=encoding)
        
    def splitfmt(self):
        return "xml"
        
    def initiate_request(self, method, args, kwargs, completion):
        if kwargs: raise NotImplemented("Keyword arguments not supported in XML-RPC mode")
        self.__queue.append(completion)
        return xmlrpc_dumps(args, method, encoding=self.__encoding, allow_none=self.__allow_none)
        
    def handle_response(self, rstr):
        completion = self.__queue.pop(0)
        try:
            response = xmlrpc_loads(rstr, self.__use_datetime)
            completion(response[0][0], None)
        except Fault as f:
            completion(None, f)
    
    def dispatch_request(self, reqstr):
        p,m = xmlrpc_loads(reqstr, self.__use_datetime)
        try:
            rsp = self.__dispatcher._dispatch(m, p)
            response = xmlrpc_dumps((rsp,), allow_none=self.__allow_none, encoding=self.__encoding)
        except Fault as fault:
            response = xmlrpc_dumps(fault, allow_none=self.__allow_none, encoding=self.__encoding)
        except:
            exc_type, exc_value, exc_tb = sys.exc_info()
            response = xmlrpc_dumps(
                Fault(1, "%s:%s" % (exc_type, exc_value)),
                encoding=self.__encoding, allow_none=self.__allow_none)
        return response
        
    def register_function(self, func, name=None):
        self.__dispatcher.register_function(func, name)
        
开发者ID:evolvIQ,项目名称:streamrpc,代码行数:42,代码来源:protocol.py

示例8: __init__

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import register_function [as 别名]
class WSGIXMLRPCApplication:
    def __init__(self,instance=None,methods=[]):
        self.dispatcher = SimpleXMLRPCDispatcher(allow_none=True,encoding=None)
        if instance is not None:
            self.dispatcher.register_instance(instance)
        for method in methods:
            self.dispatcher.register_function(method)
        self.dispatcher.register_introspection_functions()
    def __call__(self,environ,start_response):
        if environ["REQUEST_METHOD"] == "POST":
            return self.handle_post(environ,start_response)
        else:
            start_response("400 Bad request",[("Content-Type","text/plain")])
            return ['']
    def handle_post(self,environ,start_response):
        try:
            max_chunk_size = 10*1024*1024
            size_remaining = int(environ["CONTENT_LENGTH"])
            L = []
            rfile = environ['wsgi.input']
            while size_remaining:
                chunk_size = min(size_remaining, max_chunk_size)
                chunk = rfile.read(chunk_size)
                if not chunk:
                    break
                L.append(chunk)
                size_remaining -= len(L[-1])
            data = ''.join(L)
            

            data = self.decode_request_content(data,environ,start_response)
            if isinstance(data, list):
                return data 
            response = self.dispatcher._marshaled_dispatch(data)
        except Exception, e: 
            start_response("%d %s" % (500,_RESPONSE_STATUSES[500]),[
            ("Content-length", '')
            ])
            return []
        else:
开发者ID:huangnauh,项目名称:learnpython,代码行数:42,代码来源:wsgitest06.py

示例9: XMLRPCDispatcher

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import register_function [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)
开发者ID:atlas,项目名称:gates,代码行数:38,代码来源:__init__.py

示例10: __init__

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import register_function [as 别名]

#.........这里部分代码省略.........
        methods.sort()
        return methods

    @rpcmethod(name="system.methodHelp", signature=["string", "string"])
    def system_methodhelp(self, method_name):
        """
        Returns documentation for a specified method
        """

        for method in self.rpcmethods:
            if method.name == method_name:
                return method.help

        # this differs from what implementation in SimpleXMLRPCServer does
        # this will report via a fault or error while SimpleXMLRPCServer
        # just returns an empty string
        raise Fault(APPLICATION_ERROR, "No method found with name: " + str(method_name))

    @rpcmethod(name="system.methodSignature", signature=["array", "string"])
    def system_methodsignature(self, method_name):
        """
        Returns the signature for a specified method 
        """

        for method in self.rpcmethods:
            if method.name == method_name:
                return method.signature
        raise Fault(APPLICATION_ERROR, "No method found with name: " + str(method_name))

    def register_rpcmethods(self, apps):
        """
        Scans the installed apps for methods with the rpcmethod decorator
        Adds these methods to the list of methods callable via RPC
        """

        for appname in apps:
            # check each app for any rpcmethods
            app = __import__(appname, globals(), locals(), ["*"])
            for obj in dir(app):
                method = getattr(app, obj)
                if callable(method) and getattr(method, "is_rpcmethod", False):
                    # if this method is callable and it has the rpcmethod
                    # decorator, add it to the dispatcher
                    self.register_method(method, method.external_name)

    def jsondispatch(self, raw_post_data):
        """
        Sends the post data to a jsonrpc processor
        """

        return self.jsonrpcdispatcher.dispatch(raw_post_data)

    def xmldispatch(self, raw_post_data):
        """
        Sends the post data to an xmlrpc processor
        """

        return self.xmlrpcdispatcher._marshaled_dispatch(raw_post_data)

    def get_method_name(self, raw_post_data, request_format="xml"):
        """
        Gets the name of the method to be called given the post data
        and the format of the data
        """

        if request_format == "xml":
            # xmlrpclib.loads could throw an exception, but this is fine
            # since _marshaled_dispatch would throw the same thing
            try:
                params, method = xmlrpclib.loads(raw_post_data)
                return method
            except Fault:
                return None
        else:
            try:
                # attempt to do a json decode on the data
                jsondict = json.loads(raw_post_data)
                if not isinstance(jsondict, dict) or "method" not in jsondict:
                    return None
                else:
                    return jsondict["method"]
            except ValueError:
                return None

    def list_methods(self):
        """
        Returns a list of RPCMethod objects supported by the server
        """

        return self.rpcmethods

    def register_method(self, method, name=None, signature=None, helpmsg=None):
        """
        Registers a method with the rpc server
        """

        meth = RPCMethod(method, name, signature, helpmsg)
        self.xmlrpcdispatcher.register_function(method, meth.name)
        self.jsonrpcdispatcher.register_function(method, meth.name)
        self.rpcmethods.append(meth)
开发者ID:phauly,项目名称:dycapo,代码行数:104,代码来源:rpcdispatcher.py

示例11: mock_ping

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import register_function [as 别名]
    ('http://example.com/good-source-document/', 'http://example.com/blog/pingable-entry/'): 'Ping registered'
}

def mock_ping(sourceURI, targetURI):
    response = mock_responses.get((sourceURI, targetURI), Fault(0, 'Error'))
    if isinstance(response, Fault):
        raise response
    return response


try:
    dispatcher = SimpleXMLRPCDispatcher()
except TypeError:
    dispatcher = SimpleXMLRPCDispatcher(allow_none=False, encoding=None)

dispatcher.register_function(mock_ping, "pingback.ping")

def mock_pingback_server(request):
    if not request.method == 'POST':
        return HttpResponseNotAllowed(['POST'])
    response = HttpResponse(mimetype='text/xml')
    response.write(dispatcher._marshaled_dispatch(request.body))
    response['Content-Length'] = str(len(response.content))
    return response

TRACKBACK_SUCCESS_RESPONSE = '<?xml version="1.0" encoding="utf-8"?><response><error>0</error></response>'
TRACKBACK_FAILURE_RESPONSE = '<?xml version="1.0" encoding="utf-8"?><response><error>1</error><message>An error occurred</message></response>'

def mock_trackback_server(request, id):
    try:
        id = int(id)
开发者ID:hasadna,项目名称:django-backlinks,代码行数:33,代码来源:client_urls.py

示例12: rpc_handler

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import register_function [as 别名]
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
开发者ID:NGenetzky,项目名称:espa,代码行数:50,代码来源:rpc.py

示例13: len

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import register_function [as 别名]
            if len(numbers_1)!= 0:
                owner = numbers_1[0].client_id

            if len(numbers_2)!= 0:
                source = "22738"+source
                owner = numbers_2[0].client_id





            Connection.objects.create(source=source,destination=destination,
                                  duration=duration,start=start,
                                  end=end, operator=operator,
                                  uniqueid=uniqueid,host=host,type=type,
                                  owner=owner)



            return True


        #return source



dispatcher.register_function(bill, 'bill')


开发者ID:83tb,项目名称:biller,代码行数:29,代码来源:views.py

示例14: render_to_response

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import register_function [as 别名]
            # 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)

            string+= "<li><b>%s</b>: %s" % (method, help)
        string+="</ul>"
    return render_to_response("xmlrpc.html",{"appBody":string})

def multiply(a, b):
    """
    Multiplication is fun!
    Takes two arguments, which are multiplied together.
    Returns the result of the multiplication!
    """
    return a*b

# you have to manually register all functions that are xml-rpc-able with the dispatcher
# the dispatcher then maps the args down.
# The first argument is the actual method, the second is what to call it from the XML-RPC side...
dispatcher.register_function(multiply, 'multiply')
#dispatcher.register_function(get_data,'info');
dispatcher.register_function(return_array, 'test')
dispatcher.register_function(show_data,'echo')
dispatcher.register_function(save_image,'saveImage')
dispatcher.register_function(save_find,'saveFind')
dispatcher.register_function(save_instance,'saveInstance')
#dispatcher.register_introspection_functions()
开发者ID:nimbosa,项目名称:positserver,代码行数:33,代码来源:xmlrpc.py

示例15: authenticate

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import register_function [as 别名]
    if email_re.search(username):
        try:
            contact = crm.Contact.objects.get(user__email=username)
        except crm.Contact.DoesNotExist:
            contact = None
    else:
        try:
            contact = crm.Contact.objects.get(user__username=username)
        except crm.Contact.DoesNotExist:
            contact = None
    return contact


def authenticate(username, password):
    return bool(auth.authenticate(username=username, password=password))
dispatcher.register_function(authenticate, 'authenticate')


def project_relationships(project_trac_env, username):
    groups = []
    contact = _get_contact(username)
    if contact:
        groups = crm.RelationshipType.objects.filter(
            project_relationships__contact=contact,
            project_relationships__project__trac_environment=project_trac_env,
        ).values_list('slug', flat=True)
    return list(groups)
dispatcher.register_function(project_relationships, 'project_relationships')


def callerid(number):
开发者ID:MadhuPeopleLink,项目名称:django-crm,代码行数:33,代码来源:xmlrpc.py


注:本文中的SimpleXMLRPCServer.SimpleXMLRPCDispatcher.register_function方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。