コード例 #1
0
    def _marshaled_dispatch(self, request, django_args, django_kwargs):
        def dispatch_method(method, params):
            try:
                func = self.funcs[method]
            except KeyError:
                raise Exception('method "%s" is not supported' % method)

            kwargs = {}
            if django_args:
                kwargs['django_args'] = django_args
            if django_kwargs:
                kwargs['django_kwargs'] = django_kwargs
            return func(request, *params, **kwargs)

        # Tapatalk sends out bad formatted booleans... *sigh*
        body = request.raw_post_data.replace('<boolean>true</boolean>', '<boolean>1</boolean>')

        return DjangoXMLRPCDispatcher._marshaled_dispatch(self, body, dispatch_method)
コード例 #2
0
ファイル: views.py プロジェクト: ewianda/lscds-new-site
from logging import getLogger
from collections import Callable

from django.conf import settings
from django.template import RequestContext
from django.shortcuts import render_to_response
from django.core.exceptions import ImproperlyConfigured
from django.http import HttpResponse
from django.http import HttpResponseServerError
from django.views.decorators.csrf import csrf_exempt

from django_xmlrpc.decorators import xmlrpc_func
from django_xmlrpc.dispatcher import DjangoXMLRPCDispatcher

logger = getLogger('xmlrpc')
xmlrpcdispatcher = DjangoXMLRPCDispatcher(allow_none=False, encoding=None)


@xmlrpc_func(returns='string', args=['string'])
def test_xmlrpc(text):
    """Simply returns the args passed to it as a string"""
    return "Here's a response! %s" % str(text)


@csrf_exempt
def handle_xmlrpc(request):
    """Handles XML-RPC requests. All XML-RPC calls should be forwarded here

    request
        The HttpRequest object that carries the XML-RPC call. If this is a
        GET request, nothing will happen (we only accept POST requests)
コード例 #3
0
ファイル: views.py プロジェクト: diegopradogesto/MatrixWeb
from collections import Callable

from django.conf import settings
from django.template import RequestContext
from django.shortcuts import render_to_response
from django.core.exceptions import ImproperlyConfigured
from django.http import HttpResponse
from django.http import HttpResponseServerError
from django.views.decorators.csrf import csrf_exempt

from django_xmlrpc.decorators import xmlrpc_func
from django_xmlrpc.dispatcher import DjangoXMLRPCDispatcher


logger = getLogger('xmlrpc')
xmlrpcdispatcher = DjangoXMLRPCDispatcher(allow_none=False, encoding=None)


@xmlrpc_func(returns='string', args=['string'])
def test_xmlrpc(text):
    """Simply returns the args passed to it as a string"""
    return "Here's a response! %s" % str(text)


@csrf_exempt
def handle_xmlrpc(request):
    """Handles XML-RPC requests. All XML-RPC calls should be forwarded here

    request
        The HttpRequest object that carries the XML-RPC call. If this is a
        GET request, nothing will happen (we only accept POST requests)