Mark videos thumbnails with marker interface
authorThierry Florac <thierry.florac@onf.fr>
Thu, 21 Apr 2016 17:00:31 +0200
changeset 31 5d4da6163895
parent 30 a84ca4335d44
child 32 27d0b4049921
Mark videos thumbnails with marker interface
src/pyams_media/video.py
--- a/src/pyams_media/video.py	Thu Feb 25 17:12:10 2016 +0100
+++ b/src/pyams_media/video.py	Thu Apr 21 17:00:31 2016 +0200
@@ -20,7 +20,7 @@
 from tempfile import NamedTemporaryFile
 
 # import interfaces
-from pyams_file.interfaces import IVideo, IThumbnail
+from pyams_file.interfaces import IVideo, IThumbnail, IThumbnailFile
 from pyams_media.interfaces import IVideoType
 from pyams_utils.interfaces.tales import ITALESExtension
 from zope.annotation.interfaces import IAnnotations
@@ -34,7 +34,7 @@
 from pyams_media.ffbase import FFmpeg
 from pyams_utils.adapter import adapter_config, ContextAdapter, ContextRequestViewAdapter
 from pyramid.threadlocal import get_current_registry
-from zope.interface import Interface
+from zope.interface import alsoProvides, Interface
 from zope.lifecycleevent import ObjectCreatedEvent, ObjectAddedEvent
 from zope.location import locate
 
@@ -130,6 +130,7 @@
                 annotations = IAnnotations(self.video)
                 image = ImageFile(stdout)
                 image.content_type = get_magic_content_type(image.data)
+                alsoProvides(image, IThumbnailFile)
                 registry.notify(ObjectCreatedEvent(image))
                 self.thumbnail = annotations[THUMBNAIL_ANNOTATION_KEY] = image
                 locate(self.thumbnail, self.video)