diff --git a/CHANGES.rst b/CHANGES.rst index 9e0be83e8..352c035b2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,9 @@ There's a frood who really knows where his towel is. 1.0a13 (unreleased) ^^^^^^^^^^^^^^^^^^^ +- Remove Grok dependency for vocabularies. + [l34marr] + - You can now use a collection to populate a carousel tile; search results without a lead image will be bypassed (fixes `#574`_). [rodfersou] diff --git a/src/collective/cover/configure.zcml b/src/collective/cover/configure.zcml index ec74fc7d6..d5b22c6e6 100644 --- a/src/collective/cover/configure.zcml +++ b/src/collective/cover/configure.zcml @@ -19,6 +19,7 @@ + diff --git a/src/collective/cover/controlpanel.py b/src/collective/cover/controlpanel.py index 4c8e99ab1..b5dbaacda 100644 --- a/src/collective/cover/controlpanel.py +++ b/src/collective/cover/controlpanel.py @@ -27,7 +27,7 @@ class ICoverSettings(form.Schema): required=True, default=DEFAULT_AVAILABLE_TILES, value_type=schema.Choice( - vocabulary=u'collective.cover.EnabledTiles'), + vocabulary='collective.cover.EnabledTiles'), ) searchable_content_types = schema.List( @@ -38,7 +38,7 @@ class ICoverSettings(form.Schema): default=DEFAULT_SEARCHABLE_CONTENT_TYPES, # we are going to list only the main content types in the widget value_type=schema.Choice( - vocabulary=u'collective.cover.AvailableContentTypes'), + vocabulary='collective.cover.AvailableContentTypes'), ) form.widget(styles='z3c.form.browser.textlines.TextLinesFieldWidget') @@ -57,7 +57,7 @@ class ICoverSettings(form.Schema): description=_(u'Choose a grid system'), required=True, default=DEFAULT_GRID_SYSTEM, - vocabulary=u'collective.cover.GridSystems', + vocabulary='collective.cover.GridSystems', ) diff --git a/src/collective/cover/tests/test_vocabularies.py b/src/collective/cover/tests/test_vocabularies.py index 64fbe2129..c92e9c2cf 100644 --- a/src/collective/cover/tests/test_vocabularies.py +++ b/src/collective/cover/tests/test_vocabularies.py @@ -18,7 +18,7 @@ def setUp(self): self.portal = self.layer['portal'] def test_layouts_vocabulary(self): - name = u'collective.cover.AvailableLayouts' + name = 'collective.cover.AvailableLayouts' vocabulary = queryUtility(IVocabularyFactory, name) self.assertIsNotNone(vocabulary) layouts = vocabulary(self.portal) @@ -29,7 +29,7 @@ def test_layouts_vocabulary(self): self.assertIn(u'Empty layout', layouts) def test_available_tiles_vocabulary(self): - name = u'collective.cover.AvailableTiles' + name = 'collective.cover.AvailableTiles' vocabulary = queryUtility(IVocabularyFactory, name) self.assertIsNotNone(vocabulary) tiles = vocabulary(self.portal) @@ -45,7 +45,7 @@ def test_available_tiles_vocabulary(self): self.assertIn(u'collective.cover.richtext', tiles) def test_enabled_tiles_vocabulary(self): - name = u'collective.cover.EnabledTiles' + name = 'collective.cover.EnabledTiles' vocabulary = queryUtility(IVocabularyFactory, name) self.assertIsNotNone(vocabulary) tiles = vocabulary(self.portal) @@ -67,7 +67,7 @@ def test_enabled_tiles_vocabulary(self): self.assertNotIn(u'plone.app.texttile', tiles) def test_available_content_types_vocabulary(self): - name = u'collective.cover.AvailableContentTypes' + name = 'collective.cover.AvailableContentTypes' vocabulary = queryUtility(IVocabularyFactory, name) self.assertIsNotNone(vocabulary) available_content_types = vocabulary(self.portal) @@ -75,7 +75,7 @@ def test_available_content_types_vocabulary(self): self.assertNotIn(u'collective.cover.content', available_content_types) def test_tile_styles_vocabulary(self): - name = u'collective.cover.TileStyles' + name = 'collective.cover.TileStyles' vocabulary = queryUtility(IVocabularyFactory, name) self.assertIsNotNone(vocabulary) # in the beginning the vocabulary should contain the default styles @@ -105,7 +105,7 @@ def test_tile_styles_vocabulary(self): self.assertEqual(styles.by_value.keys()[0], u'tile-default') def test_grid_systems(self): - name = u'collective.cover.GridSystems' + name = 'collective.cover.GridSystems' vocabulary = queryUtility(IVocabularyFactory, name) self.assertIsNotNone(vocabulary) diff --git a/src/collective/cover/vocabularies.py b/src/collective/cover/vocabularies.py index d70d87b12..7c5d0b204 100644 --- a/src/collective/cover/vocabularies.py +++ b/src/collective/cover/vocabularies.py @@ -3,20 +3,20 @@ from collective.cover.controlpanel import ICoverSettings from collective.cover.interfaces import IGridSystem from collective.cover.tiles.base import IPersistentCoverTile -from five import grok from plone.app.vocabularies.types import ReallyUserFriendlyTypesVocabulary from plone.registry.interfaces import IRegistry from plone.tiles.interfaces import ITileType from zope.component import getUtilitiesFor from zope.component import getUtility from zope.component import queryUtility +from zope.interface import implementer from zope.schema.interfaces import IVocabularyFactory from zope.schema.vocabulary import SimpleTerm from zope.schema.vocabulary import SimpleVocabulary +@implementer(IVocabularyFactory) class AvailableLayoutsVocabulary(object): - grok.implements(IVocabularyFactory) def __call__(self, context): @@ -26,12 +26,9 @@ def __call__(self, context): items = [SimpleTerm(value=i, title=i) for i in sorted(settings.layouts)] return SimpleVocabulary(items) -grok.global_utility(AvailableLayoutsVocabulary, - name=u'collective.cover.AvailableLayouts') - +@implementer(IVocabularyFactory) class AvailableTilesVocabulary(object): - grok.implements(IVocabularyFactory) def __call__(self, context): @@ -43,26 +40,20 @@ def __call__(self, context): items = [SimpleTerm(value=i, title=i) for i in tiles] return SimpleVocabulary(items) -grok.global_utility(AvailableTilesVocabulary, - name=u'collective.cover.AvailableTiles') - +@implementer(IVocabularyFactory) class GridSystemsVocabulary(object): - grok.implements(IVocabularyFactory) def __call__(self, context): items = [SimpleTerm(value=name, title=grid.title) for (name, grid) in getUtilitiesFor(IGridSystem)] return SimpleVocabulary(items) -grok.global_utility(GridSystemsVocabulary, - name=u'collective.cover.GridSystems') - +@implementer(IVocabularyFactory) class EnabledTilesVocabulary(object): """Return a list of tiles ready to work with collective.cover. """ - grok.implements(IVocabularyFactory) def _enabled(self, name): tile_type = queryUtility(ITileType, name) @@ -80,16 +71,13 @@ def __call__(self, context): items.append(SimpleTerm(value=tile, title=tile_type.title)) return SimpleVocabulary(items) -grok.global_utility(EnabledTilesVocabulary, - name=u'collective.cover.EnabledTiles') - +@implementer(IVocabularyFactory) class AvailableContentTypesVocabulary(ReallyUserFriendlyTypesVocabulary): """ Inherit from plone.app.vocabularies.ReallyUserFriendlyTypes; and filter the results. We don't want covers to be listed. """ - grok.implements(IVocabularyFactory) def __call__(self, context): items = super(AvailableContentTypesVocabulary, self).__call__(context) @@ -97,14 +85,10 @@ def __call__(self, context): return SimpleVocabulary(items) -grok.global_utility(AvailableContentTypesVocabulary, - name=u'collective.cover.AvailableContentTypes') - - +@implementer(IVocabularyFactory) class TileStylesVocabulary(object): """Creates a vocabulary with the available styles stored in the registry. """ - grok.implements(IVocabularyFactory) def __call__(self, context): registry = getUtility(IRegistry) @@ -131,5 +115,3 @@ def __call__(self, context): items.insert(0, SimpleTerm(value=u'tile-default', title='-Default-')) return SimpleVocabulary(items) - -grok.global_utility(TileStylesVocabulary, name=u'collective.cover.TileStyles') diff --git a/src/collective/cover/vocabularies.zcml b/src/collective/cover/vocabularies.zcml new file mode 100644 index 000000000..18f72bc85 --- /dev/null +++ b/src/collective/cover/vocabularies.zcml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + +