1
0
Fork 0
gnuviechadmin-historic/backend/GnuviechAdmin/SOAPServer.py
Jan Dittberner d7980414e1 - extract logging class
- use class and namespace for services

git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@170 a67ec6bc-e5d5-0310-a910-815c51eb3124
2006-02-27 19:41:43 +00:00

66 lines
No EOL
1.8 KiB
Python

#!/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()