From 8e7c5216107e900f5a0f12b4c17fbd2cad41e931 Mon Sep 17 00:00:00 2001 From: Razvan Deaconescu Date: Mon, 22 Aug 2011 10:56:00 +0300 Subject: [PATCH] ppf: Update DatabaseAccess classes to initialize database in constructor. Previously, initilization occured in the connect() method, with the database string passed to it. Now the connect() method receives no argument; connection information had been initialized in constructor. --- ppf/new/storage.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/ppf/new/storage.py b/ppf/new/storage.py index 854a243..2bbc257 100644 --- a/ppf/new/storage.py +++ b/ppf/new/storage.py @@ -403,11 +403,10 @@ class TreeTextFileAccess(FileAccess): f.close() class DatabaseAccess(SwarmDataAccess): - def __init__(self): - pass - - def connect(self, database): + def __init__(self, database): self.database = database + + def connect(self): self.conn = None self.cursor = None @@ -416,11 +415,10 @@ class DatabaseAccess(SwarmDataAccess): self.conn.close() class SQLiteDatabaseAccess(DatabaseAccess): - def __init___(self): - pass + def __init___(self, database): + super(SQLiteDatabaseAccess, self).__init__(database) - def connect(self, database): - self.database = database + def connect(self): self.conn = sqlite3.connect(self.database) self.cursor = self.conn.cursor() @@ -440,10 +438,10 @@ class SQLiteDatabaseAccess(DatabaseAccess): pass class MySQLDatabaseAccess(DatabaseAccess): - def __init___(self): - pass + def __init___(self, database): + super(SQLiteDatabaseAccess, self).__init__(database) - def connect(self, database): + def connect(self): pass def add_swarm(self, swarm): -- 2.20.1