Changeset 7066 for main/waeup.sirp/trunk/src
- Timestamp:
- 10 Nov 2011, 13:32:33 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/imagestorage.py
r7063 r7066 209 209 grok.implements(IFileStoreNameChooser) 210 210 211 def checkName(self, name ):212 """Check whether a n object nameis valid.211 def checkName(self, name, attr=None): 212 """Check whether a given name (file id) is valid. 213 213 214 214 Raises a user error if the name is not valid. 215 215 216 For the default file store name chooser any name is valid. 216 For the default file store name chooser any name is valid as 217 long as it is a string. 218 219 The `attr` is not taken into account here. 217 220 """ 218 221 if isinstance(name, basestring): … … 220 223 return False 221 224 222 def chooseName(self, name ):223 """Choose a unique valid namefor the object.224 225 The given name and object may be taken into account when226 choosing the name.225 def chooseName(self, name, attr=None): 226 """Choose a unique valid file id for the object. 227 228 The given name may be taken into account when choosing the 229 name (file id). 227 230 228 231 chooseName is expected to always choose a valid name (that … … 230 233 231 234 For this default name chooser we return the given name if it 232 is valid or ``unknown_file`` else. 235 is valid or ``unknown_file`` else. The `attr` param is not 236 taken into account here. 233 237 """ 234 238 if self.checkName(name): -
main/waeup.sirp/trunk/src/waeup/sirp/interfaces.py
r7063 r7066 600 600 """See zope.container.interfaces.INameChooser for base methods. 601 601 """ 602 def checkName(name ):602 def checkName(name, attr=None): 603 603 """Check whether an object name is valid. 604 604 … … 606 606 """ 607 607 608 def chooseName(name): 609 """Choose a unique valid name for the object. 610 611 The given name and object may be taken into account when 612 choosing the name. 613 614 chooseName is expected to always choose a valid name (that would pass 615 the checkName test) and never raise an error. 608 def chooseName(name, attr=None): 609 """Choose a unique valid file id for the object. 610 611 The given name may be taken into account when choosing the 612 name (file id). 613 614 chooseName is expected to always choose a valid file id (that 615 would pass the checkName test) and never raise an error. 616 617 If `attr` is not ``None`` it might been taken into account as 618 well when generating the file id. Usual behaviour is to 619 interpret `attr` as a hint for what type of file for a given 620 context should be stored if there are several types 621 possible. For instance for a certain student some file could 622 be the connected passport photograph or some certificate scan 623 or whatever. Each of them has to be stored in a different 624 location so setting `attr` to a sensible value should give 625 different file ids returned. 616 626 """ 617 627 -
main/waeup.sirp/trunk/src/waeup/sirp/tests/test_imagestorage.py
r7063 r7066 158 158 self.context = context 159 159 160 def chooseName(self, name=None): 160 def chooseName(self, name=None, attr=None): 161 # this name chooser returns different file ids depending on 162 # the `attr` parameter, a simple string. 163 if attr=='img': 164 return '__mymarker__mysample.jpg' 165 elif attr=='doc': 166 return '__mymarker__mysample.doc' 161 167 return '__mymarker__mysample.txt' 162 168
Note: See TracChangeset for help on using the changeset viewer.