Changeset 1021 for pykota/trunk/pykota

Show
Ignore:
Timestamp:
06/10/03 18:37:54 (21 years ago)
Author:
jalet
Message:

Deletion of the second user which is not needed anymore.
Added a debug configuration field in /etc/pykota.conf
All queries can now be sent to the logger in debug mode, this will
greatly help improve performance when time for this will come.

Location:
pykota/trunk/pykota
Files:
1 added
2 removed
6 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/config.py

    r1000 r1021  
    2121# 
    2222# $Log$ 
     23# Revision 1.28  2003/06/10 16:37:54  jalet 
     24# Deletion of the second user which is not needed anymore. 
     25# Added a debug configuration field in /etc/pykota.conf 
     26# All queries can now be sent to the logger in debug mode, this will 
     27# greatly help improve performance when time for this will come. 
     28# 
    2329# Revision 1.27  2003/05/27 23:00:21  jalet 
    2430# Big rewrite of external accounting methods. 
     
    183189        for option in [ "storagebackend", "storageserver", \ 
    184190                        "storagename", "storageadmin", \ 
    185                         "storageuser", \ 
    186191                      ] : 
    187192            backendinfo[option] = self.getGlobalOption(option) 
    188         for option in [ "storageadminpw", "storageuserpw" ] :     
    189             backendinfo[option] = self.getGlobalOption(option, ignore=1) 
     193        backendinfo["storageadminpw"] = self.getGlobalOption("storageadminpw", ignore=1) 
    190194        return backendinfo 
    191195         
     
    304308        except ValueError :     
    305309            raise PyKotaConfigError, _("Invalid grace delay %s") % gd 
     310             
     311    def getDebug(self) :           
     312        """Returns 1 if debugging is activated, else 0.""" 
     313        debug = self.getGlobalOption("debug", ignore=1) 
     314        if (debug is not None) and (debug.upper().strip() in ['Y', 'YES', '1', 'ON', 'O']) : 
     315            return 1 
     316        else :     
     317            return 0 
  • pykota/trunk/pykota/logger.py

    r952 r1021  
    2121# 
    2222# $Log$ 
     23# Revision 1.7  2003/06/10 16:37:54  jalet 
     24# Deletion of the second user which is not needed anymore. 
     25# Added a debug configuration field in /etc/pykota.conf 
     26# All queries can now be sent to the logger in debug mode, this will 
     27# greatly help improve performance when time for this will come. 
     28# 
    2329# Revision 1.6  2003/04/23 22:13:57  jalet 
    2430# Preliminary support for LPRng added BUT STILL UNTESTED. 
     
    5561    __str__ = __repr__ 
    5662 
    57 def openLogger(config) : 
     63def openLogger(pykotatool) : 
    5864    """Returns the appropriate logger subsystem object.""" 
    59     backend = config.getLoggingBackend() 
     65    backend = pykotatool.config.getLoggingBackend() 
    6066    try : 
    6167        if not backend.isalpha() : 
  • pykota/trunk/pykota/storage.py

    r952 r1021  
    2121# 
    2222# $Log$ 
     23# Revision 1.13  2003/06/10 16:37:54  jalet 
     24# Deletion of the second user which is not needed anymore. 
     25# Added a debug configuration field in /etc/pykota.conf 
     26# All queries can now be sent to the logger in debug mode, this will 
     27# greatly help improve performance when time for this will come. 
     28# 
    2329# Revision 1.12  2003/04/23 22:13:57  jalet 
    2430# Preliminary support for LPRng added BUT STILL UNTESTED. 
     
    7884    __str__ = __repr__ 
    7985         
    80 def openConnection(config, asadmin=0) : 
     86def openConnection(pykotatool) : 
    8187    """Returns a connection handle to the appropriate Quota Storage Database.""" 
    82     backendinfo = config.getStorageBackend() 
     88    backendinfo = pykotatool.config.getStorageBackend() 
    8389    backend = backendinfo["storagebackend"] 
    8490    try : 
     
    8692            # don't trust user input 
    8793            raise ImportError 
     94        #     
     95        # TODO : descending compatibility 
     96        #  
     97        if backend == "postgresql" : 
     98            backend = "pgstorage"       # TODO : delete, this is for descending compatibility only 
    8899        exec "from pykota.storages import %s as storagebackend" % backend.lower()     
    89100    except ImportError : 
     
    93104        database = backendinfo["storagename"] 
    94105        admin = backendinfo["storageadmin"] 
    95         user = backendinfo["storageuser"] 
    96106        adminpw = backendinfo["storageadminpw"] 
    97         userpw = backendinfo["storageuserpw"] 
    98         if asadmin : 
    99             return getattr(storagebackend, "Storage")(host, database, admin, adminpw) 
    100         else :     
    101             return getattr(storagebackend, "Storage")(host, database, user, userpw) 
     107        return getattr(storagebackend, "Storage")(pykotatool, host, database, admin, adminpw) 
    102108 
  • pykota/trunk/pykota/storages/ldapstorage.py

    r1020 r1021  
    2121# 
    2222# $Log$ 
     23# Revision 1.5  2003/06/10 16:37:54  jalet 
     24# Deletion of the second user which is not needed anymore. 
     25# Added a debug configuration field in /etc/pykota.conf 
     26# All queries can now be sent to the logger in debug mode, this will 
     27# greatly help improve performance when time for this will come. 
     28# 
    2329# Revision 1.4  2003/06/10 10:45:32  jalet 
    2430# Not implemented methods now raise an exception when called. 
     
    5561     
    5662class Storage : 
    57     def __init__(self, host, dbname, user, passwd) : 
     63    def __init__(self, pykotatool, host, dbname, user, passwd) : 
    5864        """Opens the LDAP connection.""" 
    5965        # raise PyKotaStorageError, "Sorry, the LDAP backend for PyKota is not yet implemented !" 
     66        self.tool = pykotatool 
     67        self.debug = pykotatool.config.getDebug() 
    6068        self.closed = 1 
    6169        try : 
     
    6775        else :     
    6876            self.closed = 0 
     77            if self.debug : 
     78                self.tool.logger.log_message("Database opened (host=%s, dbname=%s, user=%s)" % (host, dbname, user), "debug") 
    6979             
    7080    def __del__(self) :         
     
    7383            del self.database 
    7484            self.closed = 1 
     85            if self.debug : 
     86                self.tool.logger.log_message("Database closed.", "debug") 
    7587         
    7688    def doSearch(self, key, fields, base="", scope=ldap.SCOPE_SUBTREE) : 
     
    7890        try : 
    7991            # prepends something more restrictive at the beginning of the base dn 
     92            if self.debug : 
     93                self.tool.logger.log_message("QUERY : BaseDN : %s, Scope : %s, Filter : %s, Attributes : %s" % ((base or self.basedn), scope, key, fields), "debug") 
    8094            result = self.database.search_s(base or self.basedn, scope, key, fields) 
    8195        except ldap.NO_SUCH_OBJECT :     
  • pykota/trunk/pykota/tool.py

    r973 r1021  
    2121# 
    2222# $Log$ 
     23# Revision 1.40  2003/06/10 16:37:54  jalet 
     24# Deletion of the second user which is not needed anymore. 
     25# Added a debug configuration field in /etc/pykota.conf 
     26# All queries can now be sent to the logger in debug mode, this will 
     27# greatly help improve performance when time for this will come. 
     28# 
    2329# Revision 1.39  2003/04/29 18:37:54  jalet 
    2430# Pluggable accounting methods (actually doesn't support external scripts) 
     
    188194class PyKotaTool :     
    189195    """Base class for all PyKota command line tools.""" 
    190     def __init__(self, asadmin=1, doc="PyKota %s (c) 2003 %s" % (version.__version__, version.__author__)) : 
     196    def __init__(self, doc="PyKota %s (c) 2003 %s" % (version.__version__, version.__author__)) : 
    191197        """Initializes the command line tool.""" 
    192198        # locale stuff 
     
    200206        self.documentation = doc 
    201207        self.config = config.PyKotaConfig("/etc") 
    202         self.logger = logger.openLogger(self.config) 
    203         self.storage = storage.openConnection(self.config, asadmin=asadmin) 
     208        self.logger = logger.openLogger(self) 
     209        self.storage = storage.openConnection(self) 
    204210        self.smtpserver = self.config.getSMTPServer() 
    205211         
  • pykota/trunk/pykota/version.py

    r1018 r1021  
    2121# 
    2222 
    23 __version__ = "1.08alpha7_unofficial" 
     23__version__ = "1.08alpha8_unofficial" 
    2424 
    2525__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""