Changeset 1021

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
Files:
1 added
2 removed
11 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/repykota

    r1017 r1021  
    2323# 
    2424# $Log$ 
     25# Revision 1.37  2003/06/10 16:37:54  jalet 
     26# Deletion of the second user which is not needed anymore. 
     27# Added a debug configuration field in /etc/pykota.conf 
     28# All queries can now be sent to the logger in debug mode, this will 
     29# greatly help improve performance when time for this will come. 
     30# 
    2531# Revision 1.36  2003/06/06 14:21:08  jalet 
    2632# New LDAP schema. 
     
    291297         
    292298        # Initializes the command line tool 
    293         reporter = RePyKota(asadmin=0, doc=__doc__) 
     299        reporter = RePyKota(doc=__doc__) 
    294300         
    295301        # parse and checks the command line 
  • pykota/trunk/conf/pykota.conf.sample

    r1016 r1021  
    2626[global] 
    2727# Storage backend for quotas 
    28 # only PostgreSQL is supported 
     28# only PGStorage (PostgreSQL) is supported 
    2929# Ldap, MySQL, Berkeley are planned 
    30 storagebackend: postgresql 
     30 
     31# the 'postgresql' value is deprecated, use 'pgstorage' instead. 
     32storagebackend: pgstorage 
    3133 
    3234# Quota Storage Server hostname (and optional port) 
     
    4042# Quota Storage administrator's and normal user's names and passwords 
    4143storageadmin: pykotaadmin 
    42 storageuser: pykotauser 
    4344# storageadminpw: Comment out if unused, or set to Quota Storage admin password 
    44 # storageuserpw: Comment out if unused, or set to Quota Storage user password 
     45 
     46# NB : storageuser and storageuserpw are not used anymore 
    4547 
    4648# LDAP example : 
     
    5759# if the value is not set then the default SYSTEM applies. 
    5860logger: system 
     61 
     62# Enable debugging ? Put YES instead here. 
     63debug : No 
    5964 
    6065# Mail server to use to warn users 
  • pykota/trunk/docs/installation.sgml

    r1015 r1021  
    131131        To do so, you'll have to feed <application>PostgreSQL</application> with the 
    132132        <filename>pykota-x.xx/initscripts/postgresql/pykota-postgresql.sql</filename> file. 
    133         This file will create a Quota DataBase administrator and a Quota DataBase user 
    134         in the <application>PostgreSQL</application> system, then create an empty 
     133        This file will create a Quota DataBase administrator in the <application>PostgreSQL</application> system, then create an empty 
    135134        Quota DataBase and set some permissions on it. The Quota DataBase administrator 
    136         will be able to add printers, users and groups to the Quota DataBase, while 
    137         the Quota DataBase user will be used to update the print quota usage 
    138         in the Quota DataBase. None of these two users is present in the Quota Database 
    139         itself, they are only defined in <application>PostgreSQL</application> and don't 
    140         have to exist on any system, nor in the Quota DataBase. Their default names 
    141         are <literal>pykotaadmin</literal> for the administrator and <literal>pykotauser</literal> 
    142         for the user. The database which will be created will be named <literal>pykota</literal>. 
     135        is the <application>PostgreSQL</application>'s user used to manage the Quota database. 
     136        The Quota DataBase Administrator is not present in the Quota Database 
     137        itself, he is only defined in <application>PostgreSQL</application> and don't 
     138        have to exist on any system, nor in the Quota DataBase. His default names 
     139        is <literal>pykotaadmin</literal>.  
     140        The database which will be created will be named <literal>pykota</literal> by default. 
    143141        <note> 
    144142          <title>Note</title> 
     
    179177        For security reasons, you may want to set passwords in  
    180178        <application>PostgreSQL</application> for the  
    181         <literal>pykotaadmin</literal> and <literal>pykotauser</literal>  
    182         users. Otherwise any user able to connect to  
     179        <literal>pykotaadmin</literal> user. 
     180        Otherwise any user able to connect to  
    183181        <application>PostgreSQL</application> on your Quota Storage Server  
    184         could connect to the quota database as one of them and modify it without problem.  
     182        could connect to the quota database as this user, and modify it without problem.  
    185183      </para> 
    186184       
    187185      <para> 
    188186        To do so, just type the following lines while still being at the <application>psql</application> 
    189         prompt (replace the passwords values by your own) : 
     187        prompt (replace the password values by your own) : 
    190188        <screen> 
    191189pykota=# ALTER USER pykotaadmin PASSWORD 'somepassword'; 
    192 ALTER USER 
    193 pykota=# ALTER USER pykotauser PASSWORD 'anotherpassword'; 
    194190ALTER USER 
    195191pykota=# \q 
     
    253249       
    254250      <para> 
    255         An <application>LDAP</application> Storage Backend is planned, but it actually 
    256         doesn't exist. Some people may already be working on this, though.  
     251        An <application>LDAP</application> Storage Backend is currently under heavy work. 
     252        You can already give a look at the LDAP schema which was defined for PyKota. 
     253        Full support for LDAP in PyKota should be OK by the end of July 2003, if all 
     254        continues to go well. 
    257255      </para> 
    258256    </sect2>   
     
    374372 
    375373$Log$ 
     374Revision 1.15  2003/06/10 16:37:54  jalet 
     375Deletion of the second user which is not needed anymore. 
     376Added a debug configuration field in /etc/pykota.conf 
     377All queries can now be sent to the logger in debug mode, this will 
     378greatly help improve performance when time for this will come. 
     379 
    376380Revision 1.14  2003/06/05 07:12:29  jalet 
    377381Reorganization of directories 
  • pykota/trunk/initscripts/postgresql/pykota-postgresql.sql

    r1015 r1021  
    2020-- 
    2121-- $Log$ 
     22-- Revision 1.2  2003/06/10 16:37:54  jalet 
     23-- Deletion of the second user which is not needed anymore. 
     24-- Added a debug configuration field in /etc/pykota.conf 
     25-- All queries can now be sent to the logger in debug mode, this will 
     26-- greatly help improve performance when time for this will come. 
     27-- 
    2228-- Revision 1.1  2003/06/05 07:12:31  jalet 
    2329-- Reorganization of directories 
     
    4147-- Create the print quota database users 
    4248--  
    43 CREATE USER pykotauser; 
    4449CREATE USER pykotaadmin; 
    4550 
     
    120125GRANT SELECT, INSERT, UPDATE, DELETE, REFERENCES ON users, groups, printers, userpquota, grouppquota, groupsmembers, jobhistory TO pykotaadmin; 
    121126GRANT SELECT, UPDATE ON users_id_seq, groups_id_seq, printers_id_seq, userpquota_id_seq, grouppquota_id_seq, jobhistory_id_seq TO pykotaadmin; 
    122 GRANT SELECT, UPDATE ON printers, userpquota, grouppquota TO pykotauser; 
    123 GRANT SELECT ON users, groups, groupsmembers TO pykotauser; 
    124 GRANT SELECT, INSERT, UPDATE ON jobhistory TO pykotauser; 
    125 GRANT SELECT, UPDATE ON jobhistory_id_seq TO pykotauser; 
    126127 
  • pykota/trunk/NEWS

    r1019 r1021  
    2222PyKota NEWS : 
    2323 
     24    - 1.08alpha8 : 
     25     
     26        - Code refactoring. 
     27        - A single user/password pair is used to connect 
     28          to the database backend. The storageuser configuration 
     29          field, and its associated passwords storageuserpw, are  
     30          not used anymore. 
     31         
    2432    - 1.08alpha7 : 
    2533     
  • 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."""