Added marker interface for thumbnails
authorThierry Florac <thierry.florac@onf.fr>
Thu, 21 Apr 2016 16:39:22 +0200
changeset 28 8dddc9a466e9
parent 27 792822dde705
child 29 de6720c4cf70
Added marker interface for thumbnails
src/pyams_file/interfaces/__init__.py
src/pyams_file/thumbnail.py
--- a/src/pyams_file/interfaces/__init__.py	Thu Apr 21 16:37:47 2016 +0200
+++ b/src/pyams_file/interfaces/__init__.py	Thu Apr 21 16:39:22 2016 +0200
@@ -168,6 +168,10 @@
 # Thumbnails interfaces
 #
 
+class IThumbnailFile(Interface):
+    """Marker interface for thumbnails"""
+
+
 class IThumbnailGeometry(Interface):
     """Image thumbnail geometry interface"""
 
--- a/src/pyams_file/thumbnail.py	Thu Apr 21 16:37:47 2016 +0200
+++ b/src/pyams_file/thumbnail.py	Thu Apr 21 16:39:22 2016 +0200
@@ -18,7 +18,7 @@
 import transaction
 
 # import interfaces
-from pyams_file.interfaces import IImage, IThumbnail, IThumbnailer, IFileModifiedEvent, IWatermarker
+from pyams_file.interfaces import IImage, IThumbnail, IThumbnailer, IFileModifiedEvent, IWatermarker, IThumbnailFile
 from pyams_utils.interfaces.tales import ITALESExtension
 from zope.annotation.interfaces import IAnnotations
 from zope.traversing.interfaces import ITraversable
@@ -31,7 +31,7 @@
 from pyams_utils.request import check_request
 from pyramid.events import subscriber
 from pyramid.threadlocal import get_current_registry
-from zope.interface import Interface
+from zope.interface import alsoProvides, Interface
 from zope.lifecycleevent import ObjectAddedEvent, ObjectRemovedEvent, ObjectCreatedEvent
 from zope.location import locate
 
@@ -170,6 +170,7 @@
                         thumbnail_image, format = watermarker.add_watermark(thumbnail_image, watermark)
                 # create final image
                 thumbnail_image = FileFactory(thumbnail_image)
+                alsoProvides(thumbnail_image, IThumbnailFile)
                 registry.notify(ObjectCreatedEvent(thumbnail_image))
                 self.thumbnails[name] = thumbnail_image
                 thumbnail_size = thumbnail_image.get_image_size()