Changeset 7321 for main/waeup.sirp/trunk/src/waeup/sirp/image
- Timestamp:
- 10 Dec 2011, 06:15:17 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/image
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/image/README.txt
r6584 r7321 2 2 ======================================== 3 3 4 The image file widget is built on top of the :class:` WAeUPImageFile` object::5 6 >>> from waeup.sirp.image import WAeUPImageFile7 >>> file = WAeUPImageFile('foo.jpg', 'mydata')4 The image file widget is built on top of the :class:`SIRPImageFile` object:: 5 6 >>> from waeup.sirp.image import SIRPImageFile 7 >>> file = SIRPImageFile('foo.jpg', 'mydata') 8 8 >>> file.filename 9 9 'foo.jpg' … … 16 16 'mydata' 17 17 18 We can also create WAeUPImageFile objects from file-like objects::18 We can also create SIRPImageFile objects from file-like objects:: 19 19 20 20 >>> from StringIO import StringIO … … 36 36 ---------------- 37 37 38 The WAeUPImageFile object normally stores the file data using ZODB38 The SIRPImageFile object normally stores the file data using ZODB 39 39 persistence. Files can however also be stored by tramline. If 40 40 tramline is installed in Apache, the Tramline takes care of generating … … 73 73 just '1') will now be created:: 74 74 75 >>> file = WAeUPImageFile('foo.jpg', '1')75 >>> file = SIRPImageFile('foo.jpg', '1') 76 76 77 77 The data is now '1', referring to the real file:: … … 102 102 We expect the same behavior as when tramline is not installed:: 103 103 104 >>> file = WAeUPImageFile('foo.jpg', 'data')104 >>> file = SIRPImageFile('foo.jpg', 'data') 105 105 >>> f = file.file 106 106 >>> f.read() … … 141 141 Traceback (most recent call last): 142 142 ... 143 WrongType: ('asd', <class 'waeup.sirp.image.image. WAeUPImageFile'>, 'foo')143 WrongType: ('asd', <class 'waeup.sirp.image.image.SIRPImageFile'>, 'foo') 144 144 145 145 which means: `ImageFile` fields should better contain 146 :class:` WAeUPImageFile` instances.147 148 We can store normal :class:` WAeUPImageFile` instances:149 150 >>> field.validate( WAeUPImageFile('bar.jpg', 'data')) is None146 :class:`SIRPImageFile` instances. 147 148 We can store normal :class:`SIRPImageFile` instances: 149 150 >>> field.validate(SIRPImageFile('bar.jpg', 'data')) is None 151 151 True 152 152 … … 173 173 174 174 >>> field.validate( 175 ... WAeUPImageFile('bar.jpg', '123456789012')) is None176 True 177 178 >>> field.validate( 179 ... WAeUPImageFile('bar.jpg', '12345')) is None175 ... SIRPImageFile('bar.jpg', '123456789012')) is None 176 True 177 178 >>> field.validate( 179 ... SIRPImageFile('bar.jpg', '12345')) is None 180 180 True 181 181 … … 183 183 184 184 >>> field.validate( 185 ... WAeUPImageFile('bar.jpg', '1234567890123'))185 ... SIRPImageFile('bar.jpg', '1234567890123')) 186 186 Traceback (most recent call last): 187 187 ... … … 189 189 190 190 >>> field.validate( 191 ... WAeUPImageFile('bar.jpg', '1234'))191 ... SIRPImageFile('bar.jpg', '1234')) 192 192 Traceback (most recent call last): 193 193 ... … … 198 198 ---------------------------- 199 199 200 WAeUPImageFile does not reproduce the broken unequal comparison from200 SIRPImageFile does not reproduce the broken unequal comparison from 201 201 its base: 202 202 203 >>> f1 = WAeUPImageFile('bar.jpg', '123456789')204 >>> f2 = WAeUPImageFile('bar.jpg', '123456789')205 >>> f3 = WAeUPImageFile('baz.jpg', '1234')203 >>> f1 = SIRPImageFile('bar.jpg', '123456789') 204 >>> f2 = SIRPImageFile('bar.jpg', '123456789') 205 >>> f3 = SIRPImageFile('baz.jpg', '1234') 206 206 >>> f1 == f2 207 207 True -
main/waeup.sirp/trunk/src/waeup/sirp/image/__init__.py
r7137 r7321 3 3 Includings schemas, widgets and the content components. 4 4 """ 5 from waeup.sirp.image.image import WAeUPImageFile, createWAeUPImageFile5 from waeup.sirp.image.image import SIRPImageFile, createSIRPImageFile 6 6 7 7 __all__ = [ 8 " WAeUPImageFile",9 "create WAeUPImageFile",8 "SIRPImageFile", 9 "createSIRPImageFile", 10 10 ] -
main/waeup.sirp/trunk/src/waeup/sirp/image/browser/tests/image.txt
r6537 r7321 12 12 13 13 >>> import os 14 >>> from waeup.sirp.image import WAeUPImageFile14 >>> from waeup.sirp.image import SIRPImageFile 15 15 >>> testimage = os.path.join(os.path.dirname(__file__), 'sample.jpg') 16 16 >>> testimage2 = os.path.join(os.path.dirname(__file__), 'sample2.jpg') 17 >>> some_file = WAeUPImageFile('foo.jpg', open(testimage, 'rb').read())17 >>> some_file = SIRPImageFile('foo.jpg', open(testimage, 'rb').read()) 18 18 >>> some_file.filename 19 19 'foo.jpg' … … 166 166 prepare some new file: 167 167 168 >>> another_file = WAeUPImageFile('bar.txt', 'bar contents')168 >>> another_file = SIRPImageFile('bar.txt', 'bar contents') 169 169 170 170 We happen to know, due to the implementation of … … 200 200 --------------------------- 201 201 202 As :class:`waeup.sirp.image. WAeUPImageFile` objects support storing202 As :class:`waeup.sirp.image.SIRPImageFile` objects support storing 203 203 image data by using external 'storages', also our widgets should do 204 204 so. … … 220 220 ... contents = f.read() 221 221 ... id_string = hashlib.md5(contents).hexdigest() 222 ... result = WAeUPImageFile(filename, id_string)222 ... result = SIRPImageFile(filename, id_string) 223 223 ... self.storage[id_string] = contents 224 224 ... return result … … 260 260 We now want to simulate, that the field contains already data, 261 261 identified by some `file_id`. To do so, we first store the data in our 262 file retrieval and then create a WAeUPImageFile object with that262 file retrieval and then create a SIRPImageFile object with that 263 263 file_id stored: 264 264 265 >>> from waeup.sirp.image import create WAeUPImageFile266 >>> image = create WAeUPImageFile(265 >>> from waeup.sirp.image import createSIRPImageFile 266 >>> image = createSIRPImageFile( 267 267 ... 'sample.jpg', open(testimage, 'rb')) 268 268 >>> file_id = image.data … … 274 274 '9feac4265077922000aa8b88748e25be' 275 275 276 The new file was stored by our utility, as create WAeUPImageFile looks276 The new file was stored by our utility, as createSIRPImageFile looks 277 277 up IFileRetrieval utilities and uses them: 278 278 -
main/waeup.sirp/trunk/src/waeup/sirp/image/browser/widget.py
r7196 r7321 19 19 """ 20 20 import os 21 from waeup.sirp.image import WAeUPImageFile21 from waeup.sirp.image import SIRPImageFile 22 22 from hurry.file.browser.widget import ( 23 23 EncodingFileWidget, DownloadWidget, FakeFieldStorage) … … 62 62 seek(0) 63 63 return retrieval.createFile(input.filename, input) 64 return WAeUPImageFile(input.filename, data)64 return SIRPImageFile(input.filename, data) 65 65 else: 66 66 return self.context.missing_value … … 143 143 data = file_id.decode('base64') 144 144 filename, filedata = data.split('\n', 1) 145 return WAeUPImageFile(filename, filedata)145 return SIRPImageFile(filename, filedata) 146 146 147 147 class ThumbnailWidget(DownloadWidget): -
main/waeup.sirp/trunk/src/waeup/sirp/image/image.py
r7196 r7321 23 23 from zope.component import getUtility 24 24 from zope.interface import implements 25 from waeup.sirp.image.interfaces import I WAeUPImageFile25 from waeup.sirp.image.interfaces import ISIRPImageFile 26 26 27 class WAeUPImageFile(HurryFile):27 class SIRPImageFile(HurryFile): 28 28 """A file prepared for storing image files. 29 29 … … 32 32 regular hurry files. 33 33 34 To create a :class:` WAeUPImageFile` you should use35 :func:`create WAeUPImageFile`.34 To create a :class:`SIRPImageFile` you should use 35 :func:`createSIRPImageFile`. 36 36 """ 37 implements(I WAeUPImageFile)37 implements(ISIRPImageFile) 38 38 39 39 def __ne__(self, other): … … 45 45 return True 46 46 47 def create WAeUPImageFile(filename, f):47 def createSIRPImageFile(filename, f): 48 48 retrieval = getUtility(IFileRetrieval) 49 49 return retrieval.createFile(filename, f) -
main/waeup.sirp/trunk/src/waeup/sirp/image/interfaces.py
r7196 r7321 24 24 """ 25 25 26 class I WAeUPImageFile(IHurryFile):26 class ISIRPImageFile(IHurryFile): 27 27 """Image file. 28 28 """ -
main/waeup.sirp/trunk/src/waeup/sirp/image/schema.py
r7196 r7321 23 23 from hurry.file.schema import File 24 24 from waeup.sirp.image.interfaces import IImageFile 25 from waeup.sirp.image.image import WAeUPImageFile25 from waeup.sirp.image.image import SIRPImageFile 26 26 27 27 class MinMaxSize(object): … … 82 82 implements(IImageFile) 83 83 84 _type = WAeUPImageFile84 _type = SIRPImageFile
Note: See TracChangeset for help on using the changeset viewer.