Changeset 11450 for main/waeup.kofa/trunk/src/waeup/kofa/interfaces.py
- Timestamp:
- 27 Feb 2014, 06:25:18 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/interfaces.py
r11254 r11450 36 36 from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm 37 37 from waeup.kofa.schema import PhoneNumber 38 from waeup.kofa.sourcefactory import SmartBasicContextualSourceFactory 38 39 39 40 _ = MessageFactory = zope.i18nmessageid.MessageFactory('waeup.kofa') … … 104 105 ) 105 106 107 class ContextualDictSourceFactoryBase(SmartBasicContextualSourceFactory): 108 """A base for contextual sources based on KofaUtils dicts. 109 110 To create a real source, you have to set the `DICT_NAME` attribute 111 which should be the name of a dictionary in KofaUtils. 112 """ 113 def getValues(self, context): 114 utils = getUtility(IKofaUtils) 115 return sorted(getattr(utils, self.DICT_NAME).keys()) 116 117 def getToken(self, context, value): 118 return str(value) 119 120 def getTitle(self, context, value): 121 utils = getUtility(IKofaUtils) 122 return getattr(utils, self.DICT_NAME)[value] 123 106 124 class SubjectSource(BasicSourceFactory): 107 125 """A source for school subjects used in exam documentation.
Note: See TracChangeset for help on using the changeset viewer.