# HG changeset patch # User Thierry Florac # Date 1467984948 -7200 # Node ID 06c4fcde82bc5b96f0dd982bf3df450994aaa670 # Parent 393b306a69db8e578855eaecc2595be83e5a3bbe Change sites vocabulary to display titles instead of registered names diff -r 393b306a69db -r 06c4fcde82bc src/pyams_content/shared/site/__init__.py --- a/src/pyams_content/shared/site/__init__.py Fri Jun 24 16:28:12 2016 +0200 +++ b/src/pyams_content/shared/site/__init__.py Fri Jul 08 15:35:48 2016 +0200 @@ -17,13 +17,15 @@ # import interfaces from pyams_content.shared.common.interfaces import ISharedSite +from pyams_i18n.interfaces import II18n from zope.schema.interfaces import IVocabularyFactory # import packages from pyams_utils.container import BTreeOrderedContainer -from zope.componentvocabulary.vocabulary import UtilityVocabulary +from pyams_utils.registry import get_utilities_for +from pyams_utils.request import query_request from zope.interface import provider, implementer -from zope.schema.vocabulary import getVocabularyRegistry +from zope.schema.vocabulary import getVocabularyRegistry, SimpleTerm, SimpleVocabulary @implementer(ISharedSite) @@ -32,10 +34,15 @@ @provider(IVocabularyFactory) -class SharedSiteVocabulary(UtilityVocabulary): +class SharedSiteVocabulary(SimpleVocabulary): """Shared sites vocabulary""" interface = ISharedSite - nameOnly = True + + def __init__(self, context): + request = query_request() + super(SharedSiteVocabulary, self).__init__([SimpleTerm(v, title=II18n(t).query_attribute('title', + request=request)) + for v, t in get_utilities_for(self.interface)]) getVocabularyRegistry().register('PyAMS shared sites', SharedSiteVocabulary)