summaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
Diffstat (limited to 'storage')
-rw-r--r--storage/__init__.py0
-rw-r--r--storage/factory.py5
-rw-r--r--storage/sqlite.py17
-rw-r--r--storage/storageBase.py11
4 files changed, 33 insertions, 0 deletions
diff --git a/storage/__init__.py b/storage/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/storage/__init__.py
diff --git a/storage/factory.py b/storage/factory.py
new file mode 100644
index 0000000..c1fa049
--- /dev/null
+++ b/storage/factory.py
@@ -0,0 +1,5 @@
+from sqlite import *
+
+def getStorage():
+ x = sqlite()
+ return x
diff --git a/storage/sqlite.py b/storage/sqlite.py
new file mode 100644
index 0000000..8a24858
--- /dev/null
+++ b/storage/sqlite.py
@@ -0,0 +1,17 @@
+from storageBase import storageBase
+from itemList import itemList
+from pysqlite2 import dbapi2 as sqliteBackend
+
+class sqlite(storageBase):
+ def __init__(self):
+ self.con = sqliteBackend.connect(self.getConfigDir() + '/data.sqlite')
+
+ def __del__(self):
+ self.con.close()
+
+ def load(self):
+ return itemList(self)
+
+ def notifyChange(self, sender):
+ print '%s %s' % ('Save changes:', sender.getCreatedAt())
+ return
diff --git a/storage/storageBase.py b/storage/storageBase.py
new file mode 100644
index 0000000..24abd2c
--- /dev/null
+++ b/storage/storageBase.py
@@ -0,0 +1,11 @@
+import os
+
+class storageBase:
+ def notifyChange(self, sender): abstract
+
+ def getConfigDir(self):
+ dir = os.path.expanduser('~/.todolist/blub')
+ if not os.path.exists(dir):
+ os.makedirs(dir)
+
+ return dir