• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

contrib/opal/ZSI/samples/WSGI/echo_server.py

00001 ############################################################################
00002 # Joshua R. Boverhof, LBNL
00003 # See Copyright for copyright notice!
00004 # $Id: __init__.py 1132 2006-02-17 01:55:41Z boverhof $
00005 ###########################################################################
00006 import sys
00007 from EchoServer_client import *
00008 from ZSI.twisted.wsgi import SOAPApplication, soapmethod, SOAPHandlerChainFactory
00009 
00010 class EchoService(SOAPApplication):
00011     factory = SOAPHandlerChainFactory
00012     wsdl_content = dict(name='Echo', targetNamespace='urn:echo', imports=(), portType='')
00013 
00014     @soapmethod(EchoRequest.typecode, EchoResponse.typecode, operation='Echo', soapaction='Echo')
00015     def soap_Echo(self, request, response, **kw):
00016         response = request
00017         return request,response
00018 
00019 
00020 def main():
00021     from wsgiref.simple_server import make_server, demo_app
00022     from ZSI.twisted.wsgi import WSGIApplication
00023     application = WSGIApplication()
00024     httpd = make_server('', 8000, application)
00025     application['echo'] = EchoService()
00026     httpd.serve_forever()
00027 
00028 def main_twisted():
00029     from ZSI.twisted.wsgi import test, WSGIApplication
00030     app = WSGIApplication()
00031     app['echo'] = EchoService()
00032     test(app, port=8000)
00033 
00034 if __name__ == '__main__':
00035     if len(sys.argv) == 1:
00036         main()
00037     else: 
00038         var = sys.argv[1] 
00039         try:
00040             getattr(sys.modules[__name__], 'main_%s' %var)(*sys.argv[2:])
00041         except Exception, ex:
00042             print>>sys.stderr, ex
00043             sys.exit(1)

Generated on Wed Oct 20 2010 11:12:16 for APBS by  doxygen 1.7.2