From bb89298db7f52c319995ec738648c6ffbbb41353 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 18 Jan 2017 23:25:01 +0100 Subject: Disable cache generation when loading from fixture --- ishtar_common/utils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'ishtar_common/utils.py') diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index ddd9268ce..60913851e 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -17,6 +17,7 @@ # See the file COPYING for details. +from functools import wraps import hashlib import random @@ -94,6 +95,19 @@ def mode(array): return list(set(filter(lambda x: array.count(x) == most, array))) +def disable_for_loaddata(signal_handler): + """ + Decorator that turns off signal handlers when loading fixture data. + """ + + @wraps(signal_handler) + def wrapper(*args, **kwargs): + if kwargs.get('raw'): + return + signal_handler(*args, **kwargs) + return wrapper + + def _get_image_link(item): # manage missing images if not item.thumbnail or not item.thumbnail.url: -- cgit v1.2.3