1
0
Fork 0

- 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
This commit is contained in:
Jan Dittberner 2006-02-27 19:41:43 +00:00
parent b37343bad9
commit d7980414e1
2 changed files with 32 additions and 11 deletions

View file

@ -8,30 +8,50 @@ import SOAPpy
import logging
import Settings
class SOAPServer(SOAPpy.SOAPServer):
class _GnuviechLoggingInstance:
"""
SOAP Server class for the gnuviech administration tool backend
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)
self.logger = logging.getLogger('GnuviechAdminSOAPServer')
hdlr = logging.FileHandler('soapserver.log')
hdlr.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s'))
self.logger.addHandler(hdlr)
self.logger.setLevel(logging.DEBUG)
self.logger.debug("created SOAPServer")
self.registerFunction(self.echo)
_GnuviechLoggingInstance.__init__(self, 'GnuviechAdminSOAPServer')
self.services = Services()
self.registerObject(self.services, Settings.namespace)
self.logger.debug("registered function echo")
def main(self):

View file

@ -2,7 +2,7 @@
#
# Settings for gnuviech-admin tool backend
# (c) 2006 Jan Dittberner <jan@dittberner.info>
# $Id$
# $Id:Settings.py 847 2006-02-21 21:21:30Z jan $
#
dbsettings = { 'dbuser': 'exim4',
@ -17,5 +17,6 @@ popgroup = 'poponly'
popgroup = 'poponly'
pophome = '/home/mail/'
webhome = '/home/www/'
namespace = 'urn:gnuviech-admin-services'
soapaddress = ('127.0.0.1', 8080);