2006-02-20 22:30:34 +01:00
|
|
|
#!/usr/bin/python
|
2006-02-21 11:42:14 +01:00
|
|
|
#
|
|
|
|
# File: soapserver.py
|
|
|
|
# (c) 2006 Jan Dittberner <jan@dittberner.info>
|
|
|
|
# $Id$
|
|
|
|
#
|
2006-02-21 21:22:54 +01:00
|
|
|
import SOAPpy
|
2006-02-21 11:42:14 +01:00
|
|
|
import logging
|
2006-02-21 22:21:30 +01:00
|
|
|
import Settings
|
2006-02-20 22:30:34 +01:00
|
|
|
|
2006-02-27 20:41:43 +01:00
|
|
|
class _GnuviechLoggingInstance:
|
2006-02-21 11:42:14 +01:00
|
|
|
"""
|
2006-02-27 20:41:43 +01:00
|
|
|
Logging instance base class
|
|
|
|
"""
|
|
|
|
def __init__(self, logname):
|
|
|
|
"""
|
|
|
|
Initializes a logging instance
|
|
|
|
"""
|
|
|
|
self.logger = logging.getLogger(logname)
|
|
|
|
hdlr = logging.FileHandler('soapserver.log')
|
|
|
|
hdlr.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(name)s %(message)s'))
|
|
|
|
self.logger.addHandler(hdlr)
|
|
|
|
self.logger.setLevel(logging.DEBUG)
|
|
|
|
|
|
|
|
class Services(_GnuviechLoggingInstance):
|
2006-02-21 11:42:14 +01:00
|
|
|
"""
|
2006-02-27 20:41:43 +01:00
|
|
|
The class provides all services.
|
|
|
|
"""
|
|
|
|
def __init__(self):
|
|
|
|
"""
|
|
|
|
Construtor
|
|
|
|
"""
|
|
|
|
_GnuviechLoggingInstance.__init__(self, 'GnuviechAdminServices')
|
|
|
|
|
2006-02-21 20:51:23 +01:00
|
|
|
def echo(self, param0):
|
2006-02-21 21:05:31 +01:00
|
|
|
"""
|
|
|
|
This method echoes its parameter
|
|
|
|
"""
|
2006-02-21 20:51:23 +01:00
|
|
|
self.logger.debug("calling echo with " + param0)
|
|
|
|
return param0 + param0
|
2006-02-27 20:41:43 +01:00
|
|
|
|
|
|
|
class SOAPServer(SOAPpy.SOAPServer, _GnuviechLoggingInstance):
|
|
|
|
"""
|
|
|
|
SOAP Server class for the gnuviech administration tool backend
|
|
|
|
"""
|
2006-02-21 11:42:14 +01:00
|
|
|
def __init__(self):
|
2006-02-21 21:05:31 +01:00
|
|
|
"""
|
|
|
|
This method creates the SOAPServer and registers the methods to be
|
|
|
|
available to connected SOAP clients.
|
|
|
|
"""
|
2006-02-21 21:22:54 +01:00
|
|
|
SOAPpy.SOAPServer.__init__(self, Settings.soapaddress)
|
2006-02-27 20:41:43 +01:00
|
|
|
_GnuviechLoggingInstance.__init__(self, 'GnuviechAdminSOAPServer')
|
|
|
|
self.services = Services()
|
|
|
|
self.registerObject(self.services, Settings.namespace)
|
2006-02-21 11:42:14 +01:00
|
|
|
self.logger.debug("registered function echo")
|
|
|
|
|
|
|
|
def main(self):
|
2006-02-21 21:05:31 +01:00
|
|
|
"""
|
|
|
|
Starts serving SOAP requests.
|
|
|
|
"""
|
2006-02-21 11:42:14 +01:00
|
|
|
self.logger.debug("serving SOAP")
|
2006-02-21 12:24:41 +01:00
|
|
|
self.serve_forever()
|
2006-02-21 11:42:14 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2006-02-21 21:22:54 +01:00
|
|
|
server = SOAPServer()
|
2006-02-21 11:42:14 +01:00
|
|
|
server.main()
|