ppf: Update DatabaseAccess classes to initialize database in constructor.
authorRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Mon, 22 Aug 2011 07:56:00 +0000 (10:56 +0300)
committerRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Mon, 22 Aug 2011 08:28:02 +0000 (11:28 +0300)
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

index 854a243..2bbc257 100644 (file)
@@ -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):