def __init__(self, *args, **kwds): """ __init__(self, dbhandle) __init__(self, hostname, user, password, database) __init__(self, dbhandle=, [tablename=]) __init__(self, hostname=, user=, password=, database=, [tablename=]) dbhandle: is a handle already connected to a valid database hostname: hostname of the databaseserver user: user allowed to login to the database and databaseserver password: the password for the user database: the database to use """ logging.Handler.__init__(self) self.tablename = "logs" if kwds and kwds.has_key("dbhandle"): self.dbconnection = DBConnection(dbhandle=kwds["dbhandle"]) elif kwds and kwds.has_key("hostname") and kwds.has_key( "user") and kwds.has_key("password") and kwds.has_key( "database"): self.dbconnection = DBConnection(hostname=kwds["hostname"], user=kwds["user"], password=kwds["password"], database=kwds["database"]) elif kwds: raise TypeError, "At least 1 or 4 keyword/value pairs expected. Give are " % len( kwds.keys()) if kwds: for key in kwds.keys(): setattr(self, key, kwds[key]) if args and len(args) == 1: self.dbconnection == DBConnection(dbhandle=args[0]) elif args and len(args) == 4: self.dbconnection = DBConnection(hostname=args[0], user=args[1], password=args[2], database=args[3]) elif args: raise TypeError, "Either 1 or 4-5 parameters expected. Given are %u" % len( args) if not hasattr(self, "logsource"): self.logsource = socket.gethostname()