Commit 59d142fd by Vincent Pelletier

Make storage.database.manager ctor API consistent with its subclasses.

Also, make it call _parse to simplify subclasses.
1 parent 6b6ab5d1
......@@ -122,7 +122,7 @@ def safeIter(func, *args, **kw):
class BTreeDatabaseManager(DatabaseManager):
def __init__(self, database):
super(BTreeDatabaseManager, self).__init__()
super(BTreeDatabaseManager, self).__init__(database)
......@@ -25,13 +25,16 @@ class CreationUndone(Exception):
class DatabaseManager(object):
"""This class only describes an interface for database managers."""
def __init__(self):
def __init__(self, database):
Initialize the object.
self._under_transaction = False
def _parse(self, database):
"""Called during instanciation, to process database parameter."""
def isUnderTransaction(self):
return self._under_transaction
......@@ -56,8 +56,7 @@ class MySQLDatabaseManager(DatabaseManager):
_use_partition = False
def __init__(self, database):
super(MySQLDatabaseManager, self).__init__()
self.user, self.passwd, self.db, self.socket = self._parse(database)
super(MySQLDatabaseManager, self).__init__(database)
self.conn = None
self._config = {}
......@@ -65,8 +64,8 @@ class MySQLDatabaseManager(DatabaseManager):
def _parse(self, database):
""" Get the database credentials (username, password, database) """
# expected pattern : [user[:password]@]database[unix_socket]
return re.match('(?:([^:]+)(?::(.*))?@)?([^./]+)(.+)?$',
self.user, self.passwd, self.db, self.socket = re.match(
'(?:([^:]+)(?::(.*))?@)?([^./]+)(.+)?$', database).groups()
def close(self):
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!