1
0
Fork 0
gnuviechadmin-historic/backend/GnuviechAdmin/SOAPServer.py

66 lines
1.8 KiB
Python
Raw Normal View History

#!/usr/bin/python
#
# File: soapserver.py
# (c) 2006 Jan Dittberner <jan@dittberner.info>
# $Id$
#
import SOAPpy
import logging
import Settings
class _GnuviechLoggingInstance:
"""
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):
"""
The class provides all services.
"""
def __init__(self):
"""
Construtor
"""
_GnuviechLoggingInstance.__init__(self, 'GnuviechAdminServices')
def echo(self, param0):
"""
This method echoes its parameter
"""
self.logger.debug("calling echo with " + param0)
return param0 + param0
class SOAPServer(SOAPpy.SOAPServer, _GnuviechLoggingInstance):
"""
SOAP Server class for the gnuviech administration tool backend
"""
def __init__(self):
"""
This method creates the SOAPServer and registers the methods to be
available to connected SOAP clients.
"""
SOAPpy.SOAPServer.__init__(self, Settings.soapaddress)
_GnuviechLoggingInstance.__init__(self, 'GnuviechAdminSOAPServer')
self.services = Services()
self.registerObject(self.services, Settings.namespace)
self.logger.debug("registered function echo")
def main(self):
"""
Starts serving SOAP requests.
"""
self.logger.debug("serving SOAP")
self.serve_forever()
if __name__ == "__main__":
server = SOAPServer()
server.main()