Changeset 800 for pykota/trunk

Show
Ignore:
Timestamp:
02/17/03 23:06:07 (22 years ago)
Author:
jalet
Message:

Storage backend now supports admin and user passwords (untested)

Location:
pykota/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/conf/pykota.conf.sample

    r794 r800  
    2727storageadmin: pykotaadmin 
    2828storageuser: pykotauser 
    29 # storageadminpw: NOT YET SUPPORTED 
    30 # storageuserpw: NOT YET SUPPORTED 
     29# storageadminpw: Comment out if unused 
     30# storageuserpw: Comment out if unused 
    3131 
    3232# Where to log ? 
  • pykota/trunk/pykota/config.py

    r789 r800  
    1515# 
    1616# $Log$ 
     17# Revision 1.14  2003/02/17 22:05:50  jalet 
     18# Storage backend now supports admin and user passwords (untested) 
     19# 
    1720# Revision 1.13  2003/02/10 11:47:39  jalet 
    1821# Moved some code down into the requesters 
     
    9093        for option in [ "storagebackend", "storageserver", \ 
    9194                        "storagename", "storageadmin", \ 
    92                         "storageuser", # TODO : "storageadminpw", "storageusepw", \ 
     95                        "storageuser",  
    9396                        "logger", "admin", "adminmail", 
    9497                        "smtpserver", "method", "gracedelay" ] : 
     
    130133         
    131134    def getStorageBackend(self) :     
    132         """Returns the storage backend information as a tuple. 
    133          
    134            The tuple has the form : 
    135             
    136              (backend, host, database, admin, user) 
    137         """         
    138         backendinfo = [] 
     135        """Returns the storage backend information as a Python mapping."""         
     136        backendinfo = {} 
    139137        for option in [ "storagebackend", "storageserver", \ 
    140138                        "storagename", "storageadmin", \ 
    141                         "storageuser", # TODO : "storageadminpw", "storageusepw", \ 
     139                        "storageuser", \ 
    142140                      ] : 
    143             backendinfo.append(self.config.get("global", option, raw=1)) 
    144         return tuple(backendinfo)     
     141            backendinfo[option] = self.config.get("global", option, raw=1) 
     142        for option in [ "storageadminpw", "storageuserpw" ] :     
     143            if self.config.has_option("global", option) : 
     144                backendinfo[option] = self.config.get("global", option, raw=1) 
     145            else :     
     146                backendinfo[option] = None 
     147        return backendinfo 
    145148         
    146149    def getLoggingBackend(self) :     
  • pykota/trunk/pykota/storage.py

    r791 r800  
    1515# 
    1616# $Log$ 
     17# Revision 1.8  2003/02/17 22:05:50  jalet 
     18# Storage backend now supports admin and user passwords (untested) 
     19# 
    1720# Revision 1.7  2003/02/10 12:07:31  jalet 
    1821# Now repykota should output the recorded total page number for each printer too. 
     
    109112    """Returns a connection handle to the appropriate Quota Storage Database.""" 
    110113    (backend, host, database, admin, user) = config.getStorageBackend() 
     114    backendinfo = config.getStorageBackend() 
     115    backend = backendinfo["storagebackend"] 
    111116    try : 
    112117        if not backend.isalpha() : 
     
    117122        raise PyKotaStorageError, _("Unsupported quota storage backend %s") % backend 
    118123    else :     
    119         return getattr(storagebackend, "Storage")(host, database, (asadmin and admin) or user) 
     124        host = backendinfo["storageserver"] 
     125        database = backendinfo["storagename"] 
     126        admin = backendinfo["storageadmin"] 
     127        user = backendinfo["storageuser"] 
     128        adminpw = backendinfo["storageadminpw"] 
     129        userpw = backendinfo["storageuserpw"] 
     130        if asadmin : 
     131            return getattr(storagebackend, "Storage")(host, database, admin, adminpw) 
     132        else :     
     133            return getattr(storagebackend, "Storage")(host, database, user, userpw) 
    120134 
  • pykota/trunk/pykota/storages/postgresql.py

    r720 r800  
    1515# 
    1616# $Log$ 
     17# Revision 1.4  2003/02/17 22:05:50  jalet 
     18# Storage backend now supports admin and user passwords (untested) 
     19# 
    1720# Revision 1.3  2003/02/06 14:49:04  jalet 
    1821# edpykota should be ok now 
     
    3336 
    3437class Storage(sql.SQLStorage) : 
    35     def __init__(self, host, dbname, user) : 
     38    def __init__(self, host, dbname, user, passwd) : 
    3639        """Opens the PostgreSQL database connection.""" 
    3740        self.closed = 1 
    3841        try : 
    39             self.database = pg.connect(host=host, dbname=dbname, user=user) 
     42            self.database = pg.connect(host=host, dbname=dbname, user=user, passwd=passwd) 
    4043            self.closed = 0 
    4144        except pg.error, msg :