Changeset 7016
- Timestamp:
- 7 Nov 2011, 08:12:38 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/branches/ulif-extimgstore/src/waeup/sirp/imagestorage.py
r7010 r7016 233 233 class Basket(grok.Container): 234 234 """A basket holds a set of image files with same hash. 235 236 It is used for storing files as blobs in ZODB. Current sites do 237 not use it. 238 239 .. deprecated:: 0.2 240 235 241 """ 236 242 … … 353 359 354 360 def storeFile(self, fd, filename): 361 """Store contents of file addressed by `fd` under filename `filename`. 362 363 Returns the internal file id (a string) for the file stored. 364 """ 355 365 fd.seek(0) 356 366 digest = md5digest(fd) … … 371 381 372 382 class ImageStorageFileRetrieval(Persistent): 383 """A persistent object to retrieve files stored in ZODB. 384 385 .. deprecated:: 0.2 386 387 Since we have :class:`ExtFileStore` now we do not need this 388 class anymore. 389 """ 373 390 grok.implements(IFileRetrieval) 374 391 … … 487 504 """Get a file stored under file ID `file_id`. 488 505 506 Returns a file already opened for reading. 507 489 508 If the file cannot be found ``None`` is returned. 509 510 This methods takes into account registered handlers for any 511 marker put into the file_id. 490 512 """ 491 513 marker, filename, base, ext = self.extractMarker(file_id) … … 565 587 566 588 class DefaultFileStoreHandler(grok.GlobalUtility): 589 """A default handler for external file store. 590 591 This handler is the fallback called by external file stores when 592 there is no or an unknown marker in the file id. 593 """ 567 594 grok.implements(IFileStoreHandler) 568 595 569 596 def pathFromFileID(self, store, root, file_id): 597 """Return the root path of external file store appended by file id. 598 """ 570 599 return os.path.join(root, file_id) 571 600 572 601 def createFile(self, store, root, filename, file_id, f): 602 """Infos about what to store exactly and where. 603 604 When a file should be handled by an external file storage, it 605 looks up any handlers (like this one), passes runtime infos 606 like the storage object, root path, filename, file_id, and the 607 raw file object itself. 608 609 The handler can then change the file, raise exceptions or 610 whatever and return the result. 611 612 This handler returns the input file as-is, a path returned by 613 :meth:`pathFromFileID` and an instance of 614 :class:`hurry.file.HurryFile` for further operations. 615 616 Please note: although a handler has enough infos to store the 617 file itself, it should leave that task to the calling file 618 store. 619 """ 573 620 path = self.pathFromFileID(store, root, file_id) 574 621 return f, path, HurryFile(filename, file_id)
Note: See TracChangeset for help on using the changeset viewer.