Changeset 5968 for main/waeup.sirp/trunk/src/waeup/sirp/browser/theming.py
- Timestamp:
- 23 Apr 2011, 01:46:57 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/browser/theming.py
r5963 r5968 26 26 from zope.component import getUtilitiesFor 27 27 from zope.interface import Interface 28 from waeup.sirp.interfaces import IThemesProvider 28 from zope.schema.interfaces import IVocabularyFactory 29 from waeup.sirp.interfaces import SimpleWAeUPVocabulary 29 30 from waeup.sirp.browser.interfaces import ITheme 30 31 from waeup.sirp.browser.resources import waeuptheme_red1, waeuptheme_gray1 … … 58 59 yield name, theme 59 60 60 class ThemesProvider(grok.GlobalUtility): 61 """A global utility providing all themes available. 61 class ThemesVocabulary(grok.GlobalUtility): 62 """A vocabulary that provides all themes available. 63 64 A named global utility implementing 65 66 :class:`zope.schema.interfaces.IVocabularyFactory 67 68 and registered under the name 69 70 'waeup.sirp.browser.theming.ThemesVocabulary' 71 72 Interface fields that wish to provide a list of available themes 73 can require a 'named vocabulary', i.e. set: 74 75 vocabulary = 'waeup.sirp.browser.theming.ThemesVocabulary' 76 77 and the vocabulary will deliver themes and their descriptive text 78 for instance in select boxes of forms. 79 80 The name is chosen so that the location of this vocabulary can be 81 found easily when used in an interface definition. 62 82 """ 63 grok.implements(IThemesProvider) 64 grok.name('default') 83 grok.implements(IVocabularyFactory) 84 grok.name('waeup.sirp.browser.theming.ThemesVocabulary') 85 86 def __call__(self, context): 87 """Deliver a vocabulary of available themes. 65 88 66 def __call__(self): 67 return get_all_themes() 89 The `description`s of available themes are used as 'title' and 90 the utility names delivering the different themes as 'value' 91 and 'token'. 92 """ 93 terms = [(theme.description, name) 94 for name, theme in get_all_themes()] 95 vocab = SimpleWAeUPVocabulary(*terms) 96 return vocab
Note: See TracChangeset for help on using the changeset viewer.