public
Created — forked from plq/django.py

django wrapper for rpclib

  • Download Gist
django.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
# coding: utf-8
 
# Fork of https://gist.github.com/1242760
 
from django.http import HttpResponse
from rpclib.server.wsgi import WsgiApplication
 
class DjangoApplication(WsgiApplication):
def __call__(self, request):
django_response = HttpResponse()
 
def start_response(status, headers):
status, reason = status.split(' ', 1)
 
django_response.status_code = int(status)
for header, value in headers:
django_response[header] = value
 
environ = request.META.copy()
environ['wsgi.input'] = request
environ['wsgi.multithread'] = False
 
response = WsgiApplication.__call__(self, environ, start_response)
 
django_response.content = "\n".join(response)
 
return django_response
views.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
from rpclib.server.django import DjangoApplication # not real import path.
from rpclib.service import ServiceBase
from rpclib.interface.wsdl import Wsdl11
from rpclib.protocol.soap import Soap11
from rpclib.application import Application
 
class HelloWorldService(ServiceBase):
@soap(String, Integer, _returns=Iterable(String))
def say_hello(self, name, times):
for i in xrange(times):
yield 'Hello, %s' % name
 
 
hello_world_service = DjangoApplication(Application([HelloWorldService],
'some.tns',
interface=Wsdl11(),
in_protocol=Soap11(),
out_protocol=Soap11()
))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.