diff -r a3147e47cd39 -r ad309e5090bd src/pyams_content/component/gallery/renderer.py --- a/src/pyams_content/component/gallery/renderer.py Fri Mar 02 13:48:23 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -# -# Copyright (c) 2008-2015 Thierry Florac -# All Rights Reserved. -# -# This software is subject to the provisions of the Zope Public License, -# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. -# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED -# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS -# FOR A PARTICULAR PURPOSE. -# - -__docformat__ = 'restructuredtext' - - -# import standard library - -# import interfaces -from pyams_content.component.gallery.interfaces import IBaseGallery -from pyams_content.features.renderer.interfaces import IContentRenderer - -# import packages -from pyams_content.component.gallery import Gallery -from pyams_utils.request import check_request -from pyams_utils.vocabulary import vocabulary_config -from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm - - -@vocabulary_config(name='PyAMS gallery renderers') -class GalleryRendererVocabulary(SimpleVocabulary): - """Gallery renderer utilities vocabulary""" - - def __init__(self, context=None): - request = check_request() - translate = request.localizer.translate - registry = request.registry - if not IBaseGallery.providedBy(context): - context = Gallery() - terms = [SimpleTerm(name, title=translate(adapter.label)) - for name, adapter in sorted(registry.getAdapters((context, request), IContentRenderer), - key=lambda x: x[1].weight)] - super(GalleryRendererVocabulary, self).__init__(terms)