--- a/src/pyams_content/component/gallery/__init__.py Fri Mar 02 13:48:23 2018 +0100
+++ b/src/pyams_content/component/gallery/__init__.py Fri Mar 02 13:53:12 2018 +0100
@@ -17,7 +17,7 @@
# import interfaces
from pyams_content.component.gallery.interfaces import IBaseGallery, IGallery, IGalleryTarget, \
- GALLERY_CONTAINER_KEY
+ GALLERY_CONTAINER_KEY, GALLERY_RENDERERS
from pyams_content.component.paragraph import IBaseParagraph
from pyams_content.features.checker.interfaces import IContentChecker
from pyams_content.shared.common.interfaces import IWfSharedContent
@@ -31,16 +31,19 @@
# import packages
from pyams_catalog.utils import index_object
from pyams_content.features.checker import BaseContentChecker
-from pyams_content.features.renderer import RenderedContentMixin
+from pyams_content.features.renderer import RenderedContentMixin, IContentRenderer
from pyams_utils.adapter import adapter_config, ContextAdapter
from pyams_utils.container import BTreeOrderedContainer
+from pyams_utils.request import check_request
from pyams_utils.traversing import get_parent
+from pyams_utils.vocabulary import vocabulary_config
from pyramid.events import subscriber
from pyramid.threadlocal import get_current_registry
from zope.interface import implementer
from zope.lifecycleevent import ObjectCreatedEvent, ObjectModifiedEvent
from zope.location import locate
from zope.schema.fieldproperty import FieldProperty
+from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
from pyams_content import _
@@ -177,3 +180,19 @@
def GalleryTargetContentChecker(context):
gallery = IGallery(context)
return IContentChecker(gallery, None)
+
+
+@vocabulary_config(name=GALLERY_RENDERERS)
+class GalleryRendererVocabulary(SimpleVocabulary):
+ """Gallery renderers 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)
--- a/src/pyams_content/component/gallery/interfaces/__init__.py Fri Mar 02 13:48:23 2018 +0100
+++ b/src/pyams_content/component/gallery/interfaces/__init__.py Fri Mar 02 13:53:12 2018 +0100
@@ -32,6 +32,7 @@
GALLERY_CONTAINER_KEY = 'pyams_content.gallery'
+GALLERY_RENDERERS = 'PyAMS.gallery.renderers'
class IGalleryItem(Interface):
@@ -100,7 +101,7 @@
renderer = Choice(title=_("Gallery template"),
description=_("Presentation template used for this gallery"),
- vocabulary='PyAMS gallery renderers',
+ vocabulary=GALLERY_RENDERERS,
default='hidden')
def append(self, value, notify=True):
--- 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 <tflorac AT ulthar.net>
-# 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)