# HG changeset patch # User Thierry Florac # Date 1505212569 -7200 # Node ID 426a8b8538d0a64000868d6f2e6de86e894b393a # Parent 3a73f9a24fc56ba67d15ad08e8e22b53344b7d12 Pre-generate thumbnails in image thumbnails display form to avoid broken thumbnails dur to conflict errors diff -r 3a73f9a24fc5 -r 426a8b8538d0 src/pyams_file/zmi/image.py --- a/src/pyams_file/zmi/image.py Tue Sep 12 11:29:48 2017 +0200 +++ b/src/pyams_file/zmi/image.py Tue Sep 12 12:36:09 2017 +0200 @@ -16,6 +16,7 @@ # import standard library import random import sys +import transaction from collections import OrderedDict # import interfaces @@ -684,6 +685,13 @@ adapters = sorted(registry.getAdapters((self.context, ), IThumbnailer), key=lambda x: x[1].weight) for name, adapter in adapters: + thumbnails = IThumbnail(self.context) + if name: + selection = thumbnails.get_selection(name) + transaction.commit() + thumbnails = IThumbnail(selection) + thumbnails.get_thumbnail('200x128', 'jpeg') thumbnailers.setdefault(translate(adapter.section), []).append({'name': name, 'label': translate(adapter.label)}) + transaction.commit() return thumbnailers