Updated TALES extensions interfaces
authorThierry Florac <thierry.florac@onf.fr>
Thu, 21 Sep 2017 12:42:23 +0200
changeset 57 7de6abf4258d
parent 56 44f79a6a9033
child 58 05898b7a0a73
Updated TALES extensions interfaces
src/pyams_media/media.py
src/pyams_media/video.py
--- a/src/pyams_media/media.py	Wed Sep 20 14:05:49 2017 +0200
+++ b/src/pyams_media/media.py	Thu Sep 21 12:42:23 2017 +0200
@@ -140,14 +140,14 @@
         return IMediaConversions(self.context)
 
 
-@adapter_config(name='conversions', context=(IFile, Interface, Interface), provides=ITALESExtension)
+@adapter_config(name='conversions', context=(Interface, Interface, Interface), provides=ITALESExtension)
 class ConversionsExtension(ContextRequestViewAdapter):
     """extension:conversions(media) TALES extension"""
 
     def render(self, context=None):
         if context is None:
             context = self.context
-        return IMediaConversions(context)
+        return IMediaConversions(context, None)
 
 
 #
--- a/src/pyams_media/video.py	Wed Sep 20 14:05:49 2017 +0200
+++ b/src/pyams_media/video.py	Thu Sep 21 12:42:23 2017 +0200
@@ -195,13 +195,15 @@
         return 'video/flash'
 
 
-@adapter_config(name='video_type', context=(IVideo, Interface, Interface), provides=ITALESExtension)
+@adapter_config(name='video_type', context=(Interface, Interface, Interface), provides=ITALESExtension)
 class VideoTypeExtension(ContextRequestViewAdapter):
     """extension:video_type(media) TALES extension"""
 
     def render(self, context=None):
         if context is None:
             context = self.context
+        if not IVideo.providedBy(context):
+            return None
         registry = self.request.registry
         content_type = context.content_type
         if isinstance(content_type, bytes):