diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-07-17 13:58:40 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-07-17 13:58:40 +0200 |
commit | c2f69fa7a50275841f0fbb3bd577b0ce93f122d6 (patch) | |
tree | aa74812fab75ae6263bb4eecdfd67f79f9ab27be /ishtar_common/utils.py | |
parent | 194e67bd223bfb5e32cb32162702d49c26e5fc4f (diff) | |
download | Ishtar-c2f69fa7a50275841f0fbb3bd577b0ce93f122d6.tar.bz2 Ishtar-c2f69fa7a50275841f0fbb3bd577b0ce93f122d6.zip |
Improve cached_label managemnent
* more genericity
* adapt it to archaeological files
Diffstat (limited to 'ishtar_common/utils.py')
-rw-r--r-- | ishtar_common/utils.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py new file mode 100644 index 000000000..50f4a6b41 --- /dev/null +++ b/ishtar_common/utils.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (C) 2013 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet> + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# See the file COPYING for details. + +def cached_label_changed(sender, **kwargs): + if not kwargs.get('instance'): + return + instance = kwargs.get('instance') + lbl = instance._generate_cached_label() + if lbl != instance.cached_label: + instance.cached_label = lbl + instance.save() |