Changeset 7039
- Timestamp:
- 8 Nov 2011, 21:13:59 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/branches/ulif-extimgstore/src/waeup/sirp/applicants/applicant.py
r7038 r7039 108 108 109 109 class ApplicantImageNameChooser(grok.Adapter): 110 """A file id chooser for :class:`Applicant` objects. 111 112 `context` is an :class:`Applicant` instance. 113 114 The :class:`ApplicantImageNameChooser` can build/check file ids 115 for :class:`Applicant` objects suitable for use with 116 :class:`ExtFileStore` instances. The delivered file_id contains 117 the file id marker for :class:`Applicant` object and the 118 registration number or access code of the context applicant. Also 119 the name of the connected applicant container will be part of the 120 generated file id. 121 122 This chooser is registered as an adapter providing 123 :class:`waeup.sirp.interfaces.IFileStoreNameChooser`. 124 125 File store name choosers like this one are only convenience 126 components to ease the task of creating file ids for applicant 127 objects. You are nevertheless encouraged to use them instead of 128 manually setting up filenames for applicants. 129 130 .. seealso:: :mod:`waeup.sirp.imagestorage` 131 132 """ 110 133 grok.context(IApplicant) 111 134 grok.implements(IFileStoreNameChooser) 112 135 113 136 def checkName(self, name=None): 137 """Check whether the given name is a valid file id for the context. 138 139 Returns ``True`` only if `name` equals the result of 140 :meth:`chooseName`. 141 """ 114 142 return name == self.chooseName(name, self.context) 115 143 116 144 def chooseName(self, name=None): 145 """Get a valid file id for applicant context. 146 147 *Example:* 148 149 For an applicant with registration no. ``'My_reg_no_1234'`` 150 and stored in an applicants container called 151 ``'mycontainer'``, this chooser would create: 152 153 ``'__img-applicant__mycontainer/My_reg_no_1234.jpg'`` 154 155 meaning that the passport image of this applicant would be 156 stored in the site-wide file storage in path: 157 158 ``mycontainer/My_reg_no_1234.jpg`` 159 160 If the context applicant has no parent, ``'_default'`` is used 161 as parent name. 162 """ 117 163 parent_name = getattr( 118 164 getattr(self.context, '__parent__', None),
Note: See TracChangeset for help on using the changeset viewer.