From 36add653a70ae744323a885408ae029d62c2f0dc Mon Sep 17 00:00:00 2001 From: posativ Date: Tue, 16 Oct 2012 21:04:20 +0200 Subject: [PATCH] change modified timestamp after update --- isso/comments.py | 1 - isso/db.py | 5 +++++ specs/test_db.py | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/isso/comments.py b/isso/comments.py index d2db16a..acd4291 100644 --- a/isso/comments.py +++ b/isso/comments.py @@ -63,6 +63,5 @@ class Comment(object): return self.mode == 2 - def comment(app, environ, request, path, id=None): return Response('', 200) diff --git a/isso/db.py b/isso/db.py index 42b1337..f57fa58 100644 --- a/isso/db.py +++ b/isso/db.py @@ -1,5 +1,6 @@ import abc +import time import sqlite3 from os.path import join @@ -94,6 +95,10 @@ class SQLite(Abstract): for field, value in comment.iteritems(): con.execute('UPDATE comments SET %s=? WHERE path=? AND id=?;' % field, (value, id, path)) + + with sqlite3.connect(self.dbpath) as con: + con.execute('UPDATE comments SET modified=? WHERE path=? AND id=?', + (time.time(), path, id)) return path, id def get(self, path, id): diff --git a/specs/test_db.py b/specs/test_db.py index 852315a..a0fdb02 100644 --- a/specs/test_db.py +++ b/specs/test_db.py @@ -1,6 +1,7 @@ import os import json +import time import tempfile import unittest @@ -48,11 +49,13 @@ class TestSQLite(unittest.TestCase): def test_update(self): path, id = self.db.add('/', comment(text='Foo')) + time.sleep(0.1) path, id = self.db.update(path, id, comment(text='Bla')) c = self.db.get(path, id) assert c.id == 1 assert c.text == 'Foo' + assert c.created < c.modified def test_delete(self):