diff --git a/isso/__init__.py b/isso/__init__.py index 4cd1eef..55f9684 100644 --- a/isso/__init__.py +++ b/isso/__init__.py @@ -26,7 +26,7 @@ from werkzeug.serving import run_simple from werkzeug.wrappers import Request, Response from werkzeug.exceptions import HTTPException, NotFound, NotImplemented, InternalServerError -from isso import admin, comments +from isso import admin, comments, db url_map = Map([ # moderation panel @@ -42,8 +42,8 @@ url_map = Map([ class Isso: def __init__(self, conf): - self.conf = conf + self.db = db.SQLite(conf) def dispatch(self, request, start_response): adapter = url_map.bind_to_environ(request.environ) diff --git a/isso/db.py b/isso/db.py index 9cc689f..7c692cf 100644 --- a/isso/db.py +++ b/isso/db.py @@ -3,8 +3,6 @@ import abc import time import sqlite3 -from os.path import join - from isso.models import Comment @@ -13,7 +11,7 @@ class Abstract: __metaclass__ = abc.ABCMeta @abc.abstractmethod - def initialize(self, conf): + def __init__(self, conf): return @abc.abstractmethod @@ -48,7 +46,7 @@ class SQLite(Abstract): 'text', 'author', 'email', 'website', 'parent', 'mode' ] - def initialize(self, conf): + def __init__(self, conf): self.dbpath = conf['SQLITE'] self.mode = 1 if conf.get('MODERATION') else 0 @@ -82,7 +80,7 @@ class SQLite(Abstract): with sqlite3.connect(self.dbpath) as con: keys = ','.join(self.fields) values = ','.join('?'*len(self.fields)) - x = con.execute('INSERT INTO comments (%s) VALUES (%s);' % (keys, values), ( + con.execute('INSERT INTO comments (%s) VALUES (%s);' % (keys, values), ( 0, path, c.created, c.modified, c.text, c.author, c.email, c.website, c.parent, self.mode) ) diff --git a/specs/test_db.py b/specs/test_db.py index 8098390..4fc8b97 100644 --- a/specs/test_db.py +++ b/specs/test_db.py @@ -18,8 +18,7 @@ class TestSQLite(unittest.TestCase): def setUp(self): fd, self.path = tempfile.mkstemp() - self.db = SQLite() - self.db.initialize({'SQLITE': self.path}) + self.db = SQLite({'SQLITE': self.path}) def test_get(self):