Changed vocabulary declaration
authorThierry Florac <thierry.florac@onf.fr>
Tue, 15 Nov 2016 10:00:21 +0100
changeset 37 96802026ce25
parent 36 f50bf06ce578
child 38 57fd58ea854b
Changed vocabulary declaration
src/pyams_media/converter.py
src/pyams_media/video.py
--- a/src/pyams_media/converter.py	Thu Apr 21 17:11:44 2016 +0200
+++ b/src/pyams_media/converter.py	Tue Nov 15 10:00:21 2016 +0100
@@ -27,8 +27,9 @@
 from pyams_media.ffdocument import FFDocument
 from pyams_utils.list import unique
 from pyams_utils.registry import utility_config, get_utilities_for, query_utility
+from pyams_utils.vocabulary import vocabulary_config
 from zope.interface import implementer
-from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm, getVocabularyRegistry
+from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
 
 from pyams_media import _
 
@@ -121,6 +122,7 @@
     format = 'ogg'
 
 
+@vocabulary_config(name='PyAMS media audio converters')
 class AudioConvertersVocabulary(SimpleVocabulary):
     """Audio converters vocabulary"""
 
@@ -130,8 +132,6 @@
                  if IMediaAudioConverter.providedBy(util)]
         super(AudioConvertersVocabulary, self).__init__(terms)
 
-getVocabularyRegistry().register('PyAMS media audio converters', AudioConvertersVocabulary)
-
 
 #
 # Video converters
@@ -233,6 +233,7 @@
         effects['r:v'] = '25/1'
 
 
+@vocabulary_config(name='PyAMS media video converters')
 class VideoConvertersVocabulary(SimpleVocabulary):
     """Video converters vocabulary"""
 
@@ -241,5 +242,3 @@
                  for name, util in unique(get_utilities_for(IMediaConverter))
                  if IMediaVideoConverter.providedBy(util)]
         super(VideoConvertersVocabulary, self).__init__(terms)
-
-getVocabularyRegistry().register('PyAMS media video converters', VideoConvertersVocabulary)
--- a/src/pyams_media/video.py	Thu Apr 21 17:11:44 2016 +0200
+++ b/src/pyams_media/video.py	Tue Nov 15 10:00:21 2016 +0100
@@ -30,7 +30,7 @@
 import transaction
 
 from pyams_file.file import ImageFile, get_magic_content_type
-from pyams_file.image import ThumbnailGeometrry
+from pyams_file.image import ThumbnailGeometry
 from pyams_media.ffbase import FFmpeg
 from pyams_utils.adapter import adapter_config, ContextAdapter, ContextRequestViewAdapter
 from pyramid.threadlocal import get_current_registry
@@ -74,22 +74,22 @@
         else:
             return self.get_image_size()
 
-    def get_thumbnail_geometry(self, thumbnail_name):
+    def get_geometry(self, selection_name):
         if self.thumbnail is not None:
-            return IThumbnail(self.thumbnail).get_thumbnail_geometry(thumbnail_name)
+            return IThumbnail(self.thumbnail).get_geometry(selection_name)
         else:
             size = self.get_image_size()
             if size:
-                geometry = ThumbnailGeometrry()
+                geometry = ThumbnailGeometry()
                 geometry.x1 = 0
                 geometry.y1 = 0
                 geometry.x2 = size[0]
                 geometry.y2 = size[1]
                 return geometry
 
-    def set_thumbnail_geometry(self, thumbnail_name, geometry):
+    def set_geometry(self, selection_name, geometry):
         if self.thumbnail is not None:
-            IThumbnail(self.thumbnail).set_thumbnail_geometry(thumbnail_name, geometry)
+            IThumbnail(self.thumbnail).set_geometry(selection_name, geometry)
 
     def clear_geometries(self):
         if self.thumbnail is not None: