Changeset e64ab6 in indico for indico/MaKaC/common/db.py
- Timestamp:
- 09/11/09 14:58:05 (4 years ago)
- Branches:
- master, burotel, hello-world-walkthrough, ipv6, new-improved-taskdaemon, new-webex, prov-dual-interface, v0.97-series, v0.98-series, v0.98.2, v0.98.3, v0.98b1, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, d9941f8582b36b24821a11ea5ba16fda6a457fb1
- Children:
- 6e28cf
- Parents:
- d44cf5
- File:
-
- 1 edited
-
indico/MaKaC/common/db.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
indico/MaKaC/common/db.py
rfd0c10 re64ab6 74 74 _instance = None 75 75 76 def __init__( self ):76 def __init__( self, hostname=None, port=None ): 77 77 import Configuration # Please leave this import here, db.py is imported during installation process 78 78 cfg = Configuration.Config.getInstance() 79 self._storage=ClientStorage(cfg.getDBConnectionParams(), username=cfg.getDBUserName(), password=cfg.getDBPassword(), realm=cfg.getDBRealm()) 79 80 if not hostname: 81 hostname = cfg.getDBConnectionParams()[0] 82 if not port: 83 port = cfg.getDBConnectionParams()[1] 84 85 self._storage=ClientStorage((hostname, port), username=cfg.getDBUserName(), password=cfg.getDBPassword(), realm=cfg.getDBRealm()) 80 86 self._db=MaKaCDB(self._storage) 81 87 self._conn={} 82 88 83 89 @classmethod 84 def getInstance( cls ):90 def getInstance( cls, *args, **kwargs ): 85 91 if cls._instance == None: 86 92 Logger.get('dbmgr').debug('cls._instance is None') 87 cls._instance=DBMgr( )93 cls._instance=DBMgr(*args, **kwargs) 88 94 return cls._instance 89 90 @classmethod91 def initializeAndGetInstance(cls, address, username = '', password = '', realm = ''):92 """ Use this method when you need to create a DBMgr that will not use the "standard" address and port93 (who are normally retrieved from Config, i.e. indico.conf).94 Its implementation is quite hacky so that we don't change at all the getInstance and __init__ methods used in many places in Indico.95 """96 if cls._instance == None:97 Logger.get('dbmgr').debug('cls._instance is None (initializeAndGetInstance)')98 99 class CustomDBMgr: # we need this old-style class because DBMgr is an old-style class and we cannot change the class of an object from new-style to old-style100 pass # if DBMgr is ever changed to new-style (inherit from object) then we could initialize 'o' in a simpler way with "o = object()"101 o = CustomDBMgr()102 o.__class__ = cls # cls = DBMgr103 104 o._storage = ClientStorage(address, username=username, password=password, realm=realm)105 o._db = MaKaCDB(o._storage)106 o._conn = {}107 108 cls._instance = o109 110 return cls._instance111 112 95 113 96 def _getConnObject(self):
Note: See TracChangeset
for help on using the changeset viewer.
