replace db.initialize with db.__init__
This commit is contained in:
parent
98c4b6ccb2
commit
8301f0af78
@ -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)
|
||||
|
@ -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)
|
||||
)
|
||||
|
@ -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):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user