Changeset 697

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

import statement didn't work as expected

Location:
pykota/trunk/pykota
Files:
3 modified

Legend:

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

    r695 r697  
    1515# 
    1616# $Log$ 
     17# Revision 1.2  2003/02/05 22:02:22  jalet 
     18# __import__ statement didn't work as expected 
     19# 
    1720# Revision 1.1  2003/02/05 21:28:17  jalet 
    1821# Initial import into CVS 
     
    3639    backend = config.getLoggingBackend() 
    3740    try : 
    38         module = __import__("pykota.loggers." + backend.lower()) 
     41        if not isalpha(backend) : 
     42            # don't trust user input 
     43            raise ImportError 
     44        exec "from pykota.loggers import %s as loggingbackend" % backend.lower()     
    3945    except ImportError : 
    4046        raise PyKotaLoggingError, "Unsupported logging subsystem %s" % backend 
    4147    else :     
    42         return getattr(module, "Logger")() 
     48        return getattr(loggingbackend, "Logger")() 
  • pykota/trunk/pykota/requester.py

    r695 r697  
    1515# 
    1616# $Log$ 
     17# Revision 1.2  2003/02/05 22:02:22  jalet 
     18# __import__ statement didn't work as expected 
     19# 
    1720# Revision 1.1  2003/02/05 21:28:17  jalet 
    1821# Initial import into CVS 
     
    3437    backend = config.getRequesterBackend(printername) 
    3538    try : 
    36         module = __import__("pykota.requesters." + backend.lower()) 
     39        if not isalpha(backend) : 
     40            # don't trust user input 
     41            raise ImportError 
     42        exec "from pykota.requesters import %s as requesterbackend" % backend.lower()     
    3743    except ImportError : 
    3844        raise PyKotaRequesterError, "Unsupported requester backend %s" % backend 
    3945    else :     
    40         return getattr(module, "Requester")(config, printername) 
     46        return getattr(requesterbackend, "Requester")(config, printername) 
  • pykota/trunk/pykota/storage.py

    r695 r697  
    1515# 
    1616# $Log$ 
     17# Revision 1.2  2003/02/05 22:02:22  jalet 
     18# __import__ statement didn't work as expected 
     19# 
    1720# Revision 1.1  2003/02/05 21:28:17  jalet 
    1821# Initial import into CVS 
     
    3437    (backend, host, database, admin, user) = config.getStorageBackend() 
    3538    try : 
    36         module = __import__("pykota.storages." + backend.lower()) 
     39        if not isalpha(backend) : 
     40            # don't trust user input 
     41            raise ImportError 
     42        exec "from pykota.storages import %s as storagebackend" % backend.lower()     
    3743    except ImportError : 
    3844        raise PyKotaStorageError, "Unsupported quota storage backend %s" % backend 
    3945    else :     
    40         return getattr(module, "Storage")(host, database, (asadmin and admin) or user) 
     46        return getattr(storagebackend, "Storage")(host, database, (asadmin and admin) or user)