From b0123d844195800cad0e767084cb2e26d2a3f74b Mon Sep 17 00:00:00 2001 From: sebalix Date: Thu, 2 Apr 2015 12:31:38 +0200 Subject: [PATCH] [FIX] Module 'auditlog' - Support 'read' calls with one ID or a list of IDs --- auditlog/models/rule.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/auditlog/models/rule.py b/auditlog/models/rule.py index 9549a7d5b..10cf6a2d6 100644 --- a/auditlog/models/rule.py +++ b/auditlog/models/rule.py @@ -219,9 +219,11 @@ class auditlog_rule(models.Model): def read(self, *args, **kwargs): result = read.origin(self, *args, **kwargs) # Sometimes the result is not a list but a dictionary - if not isinstance(result, list): - result = [result] - read_values = dict((d['id'], d) for d in result) + # Also, we can not modify the current result as it will break calls + result2 = result + if not isinstance(result2, list): + result2 = [result] + read_values = dict((d['id'], d) for d in result2) # Old API if args and isinstance(args[0], sql_db.Cursor): cr, uid, ids = args[0], args[1], args[2]