Changeset 11450 for main/waeup.kofa/trunk/src/waeup/kofa/university
- Timestamp:
- 27 Feb 2014, 06:25:18 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/university/vocabularies.py
r10831 r11450 21 21 from zope.catalog.interfaces import ICatalog 22 22 from zope.component import getUtility, queryUtility 23 from waeup.kofa.interfaces import SimpleKofaVocabulary, IKofaUtils 23 from waeup.kofa.interfaces import ( 24 SimpleKofaVocabulary, IKofaUtils, ContextualDictSourceFactoryBase) 24 25 from waeup.kofa.interfaces import MessageFactory as _ 25 26 from waeup.kofa.sourcefactory import SmartBasicContextualSourceFactory … … 39 40 (_('Postgraduate Level'),999), 40 41 ) 41 42 #: An instance of :class:`waeup.kofa.utils.utils.KofaUtils` for fallback.43 KOFA_UTILS = KofaUtils()44 45 class ContextualDictSourceFactoryBase(SmartBasicContextualSourceFactory):46 """A base for contextual sources based on KofaUtils dicts.47 48 To create a real source, you have to set the `DICT_NAME` attribute49 which should be the name of a dictionary in KofaUtils.50 """51 def getValues(self, context):52 utils = queryUtility(IKofaUtils, default=KOFA_UTILS)53 return sorted(getattr(utils, self.DICT_NAME).keys())54 55 def getToken(self, context, value):56 return str(value)57 58 def getTitle(self, context, value):59 utils = queryUtility(IKofaUtils, default=KOFA_UTILS)60 return getattr(utils, self.DICT_NAME)[value]61 42 62 43 class SemesterSource(ContextualDictSourceFactoryBase):
Note: See TracChangeset for help on using the changeset viewer.