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 logging
import Settings 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): def echo(self, param0):
""" """
This method echoes its parameter This method echoes its parameter
""" """
self.logger.debug("calling echo with " + param0) self.logger.debug("calling echo with " + param0)
return param0 + param0 return param0 + param0
class SOAPServer(SOAPpy.SOAPServer, _GnuviechLoggingInstance):
"""
SOAP Server class for the gnuviech administration tool backend
"""
def __init__(self): def __init__(self):
""" """
This method creates the SOAPServer and registers the methods to be This method creates the SOAPServer and registers the methods to be
available to connected SOAP clients. available to connected SOAP clients.
""" """
SOAPpy.SOAPServer.__init__(self, Settings.soapaddress) SOAPpy.SOAPServer.__init__(self, Settings.soapaddress)
self.logger = logging.getLogger('GnuviechAdminSOAPServer') _GnuviechLoggingInstance.__init__(self, 'GnuviechAdminSOAPServer')
hdlr = logging.FileHandler('soapserver.log') self.services = Services()
hdlr.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s')) self.registerObject(self.services, Settings.namespace)
self.logger.addHandler(hdlr)
self.logger.setLevel(logging.DEBUG)
self.logger.debug("created SOAPServer")
self.registerFunction(self.echo)
self.logger.debug("registered function echo") self.logger.debug("registered function echo")
def main(self): def main(self):

View file

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