Changeset 6075 for main/waeup.sirp/trunk/src
- Timestamp:
- 14 May 2011, 00:25:23 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py
r6073 r6075 27 27 from zc.sourcefactory.basic import BasicSourceFactory 28 28 from zope import schema 29 from zope.component import getUtility, getUtilitiesFor 29 30 from zope.interface import Interface, Attribute 30 31 from zope.pluggableauth.interfaces import IPrincipalInfo … … 33 34 from waeup.sirp.image.image import WAeUPImageFile 34 35 from waeup.sirp.interfaces import IWAeUPObject, SimpleWAeUPVocabulary 35 from zope.component import getAllUtilitiesRegisteredFor 36 36 37 37 38 IMAGE_PATH = os.path.join( … … 83 84 84 85 class ApplicantContainerProviderSource(BasicSourceFactory): 85 """ 86 """A source offering all available applicants container types. 87 88 The values returned by this source are names of utilities that can 89 create :class:`ApplicantContainer` instances. So, if you get a 90 name like ``'myactype'`` from this source, then you can do: 91 92 >>> from zope.component import getUtility 93 >>> p = getUtility(IApplicantsContainerProvider, name=myactype) 94 >>> my_applicants_container = p.factory() 95 96 Or you can access class-attributes like 97 98 >>> my_applicants_container.container_title 99 'Pretty' 100 86 101 """ 87 102 def getValues(self): 88 providers = getAllUtilitiesRegisteredFor(IApplicantsContainerProvider) 89 return providers 103 """Returns a list of ``(<name>, <provider>)`` tuples. 104 105 Here ``<name>`` is the name under which an 106 :class:``ApplicantContainerProvider`` was registered as a 107 utility and ``<provider>`` is the utility itself. 108 """ 109 return getUtilitiesFor(IApplicantsContainerProvider) 90 110 91 111 def getToken(self, value): 92 return getattr(value, 'grokcore.component.directive.name') 93 112 """Return the name of the ``(<name>, <provider>)`` tuple. 113 """ 114 return value[0] 115 94 116 def getTitle(self, value): 95 return "%s - %s" % (value.factory.title, value.factory.description) 117 """Get a 'title - description' string for a container type. 118 """ 119 factory = value[1].factory 120 return "%s - %s" % ( 121 factory.container_title, factory.container_description) 96 122 97 123 class IResultEntry(IWAeUPObject): … … 118 144 """ 119 145 146 container_title = Attribute( 147 u'classattribute: title for type of container') 148 container_description = Attribute( 149 u'classattribute: description for type of container') 150 151 120 152 code = schema.TextLine( 121 153 title = u'Code',
Note: See TracChangeset for help on using the changeset viewer.