add path to comment class

pull/16/head
posativ 12 years ago
parent 05b77f99fe
commit 7420e6a130

@ -75,7 +75,7 @@ class SQLite(Abstract):
post) are ordered by that id."""
fields = [
'id', 'path', 'created', 'modified',
'path', 'id', 'created', 'modified',
'text', 'author', 'email', 'website', 'parent', 'mode'
]
@ -85,7 +85,7 @@ class SQLite(Abstract):
self.mode = 2 if app.MODERATION else 1
with sqlite3.connect(self.dbpath) as con:
sql = ('main.comments (id INTEGER NOT NULL, path VARCHAR(255) NOT NULL,'
sql = ('main.comments (path VARCHAR(255) NOT NULL, id INTEGER NOT NULL,'
'created FLOAT NOT NULL, modified FLOAT, text VARCHAR,'
'author VARCHAR(64), email VARCHAR(64), website VARCHAR(64),'
'parent INTEGER, mode INTEGER, PRIMARY KEY (id, path))')
@ -105,8 +105,8 @@ class SQLite(Abstract):
return None
return Comment(
text=query[4], author=query[5], email=query[6], website=query[7],
parent=query[8], mode=query[9], id=query[0], created=query[2], modified=query[3]
text=query[4], author=query[5], email=query[6], website=query[7], parent=query[8],
path=query[0], id=query[1], created=query[2], modified=query[3], mode=query[9],
)
def add(self, path, c):
@ -114,7 +114,7 @@ class SQLite(Abstract):
keys = ','.join(self.fields)
values = ','.join('?' * len(self.fields))
con.execute('INSERT INTO comments (%s) VALUES (%s);' % (keys, values), (
0, path, c.created, c.modified, c.text, c.author, c.email, c.website,
path, 0, c.created, c.modified, c.text, c.author, c.email, c.website,
c.parent, self.mode)
)

@ -22,7 +22,7 @@ class Comment(object):
normal and queued using MODE=3.
"""
protected = ['id', 'mode', 'created', 'modified']
protected = ['path', 'id', 'mode', 'created', 'modified']
fields = ['text', 'author', 'email', 'website', 'parent']
def __init__(self, **kw):

@ -37,6 +37,7 @@ class TestSQLite(unittest.TestCase):
rv = list(self.db.retrieve('/'))
assert rv[0].id == 1
assert rv[0].path == '/'
assert rv[0].text == 'Foo'
assert rv[1].id == 2
@ -44,6 +45,7 @@ class TestSQLite(unittest.TestCase):
rv = list(self.db.retrieve('/path/'))
assert rv[0].id == 1
assert rv[0].path == '/path/'
assert rv[0].text == 'Baz'
def test_add_return(self):

Loading…
Cancel
Save