From c5d52721c4250d8b1b030662c5679caec50109e2 Mon Sep 17 00:00:00 2001 From: Martin Zimmermann Date: Fri, 1 Nov 2013 17:02:08 +0100 Subject: [PATCH] use cache.delete a) with an actual key and b) only on delete --- isso/views/comment.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/isso/views/comment.py b/isso/views/comment.py index ecde525..a8d13c6 100644 --- a/isso/views/comment.py +++ b/isso/views/comment.py @@ -166,7 +166,6 @@ def single(app, environ, request, id): for key in set(rv.keys()) - FIELDS: rv.pop(key) - app.cache.delete('hash', id) logger.info('comment %i edited: %s', id, json.dumps(rv)) checksum = hashlib.md5(rv["text"].encode('utf-8')).hexdigest() @@ -178,12 +177,14 @@ def single(app, environ, request, id): if request.method == 'DELETE': + item = app.db.comments.get(id) + app.cache.delete('hash', item['email'] or item['remote_addr']) + rv = app.db.comments.delete(id) if rv: for key in set(rv.keys()) - FIELDS: rv.pop(key) - app.cache.delete('hash', id) logger.info('comment %i deleted', id) resp = Response(json.dumps(rv), 200, content_type='application/json')