From 9e4e6b7727df521bd187ca209e2a0ebc10f4a382 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Thu, 16 Apr 2009 10:42:24 +0200 Subject: first trys --- storage/__init__.py | 0 storage/factory.py | 5 +++++ storage/sqlite.py | 17 +++++++++++++++++ storage/storageBase.py | 11 +++++++++++ 4 files changed, 33 insertions(+) create mode 100644 storage/__init__.py create mode 100644 storage/factory.py create mode 100644 storage/sqlite.py create mode 100644 storage/storageBase.py (limited to 'storage') diff --git a/storage/__init__.py b/storage/__init__.py new file mode 100644 index 0000000..e69de29 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 -- cgit v1.2.3