Renamed IThumbnail interface to IThumbnails
authorThierry Florac <thierry.florac@onf.fr>
Thu, 05 Jul 2018 15:02:24 +0200
changeset 117 2d6c635c323f
parent 116 918be17c7fef
child 118 b25ff18873d6
Renamed IThumbnail interface to IThumbnails
src/pyams_file/image.py
src/pyams_file/interfaces/__init__.py
src/pyams_file/thumbnail.py
src/pyams_file/widget/__init__.py
src/pyams_file/zmi/image.py
--- a/src/pyams_file/image.py	Mon Jul 02 17:13:55 2018 +0200
+++ b/src/pyams_file/image.py	Thu Jul 05 15:02:24 2018 +0200
@@ -20,7 +20,7 @@
 from PIL import Image, ImageFilter
 
 # import interfaces
-from pyams_file.interfaces import IImage, IThumbnailer, IThumbnailGeometry, IThumbnail, IResponsiveImage
+from pyams_file.interfaces import IImage, IThumbnailer, IThumbnailGeometry, IThumbnails, IResponsiveImage
 
 # import packages
 from pyams_utils.adapter import ContextAdapter, adapter_config
@@ -105,7 +105,7 @@
     def create_thumbnail(self, target, format=None):
         # get thumbnail size
         if isinstance(target, str):
-            geometry = IThumbnail(self.context).get_geometry(target)
+            geometry = IThumbnails(self.context).get_geometry(target)
             match = THUMB_SIZE.match(target)
             if match:
                 width, height = tuple(map(int, match.groups()))
--- a/src/pyams_file/interfaces/__init__.py	Mon Jul 02 17:13:55 2018 +0200
+++ b/src/pyams_file/interfaces/__init__.py	Thu Jul 05 15:02:24 2018 +0200
@@ -255,7 +255,7 @@
         """
 
 
-class IThumbnail(Interface):
+class IThumbnails(Interface):
     """Image thumbnail interface
 
     Displays are images thumbnails generated 'on the fly' and stored into image
--- a/src/pyams_file/thumbnail.py	Mon Jul 02 17:13:55 2018 +0200
+++ b/src/pyams_file/thumbnail.py	Thu Jul 05 15:02:24 2018 +0200
@@ -18,7 +18,7 @@
 import transaction
 
 # import interfaces
-from pyams_file.interfaces import IImage, IThumbnail, IThumbnailer, IFileModifiedEvent, IWatermarker, IThumbnailFile
+from pyams_file.interfaces import IImage, IThumbnails, IThumbnailer, IFileModifiedEvent, IWatermarker, IThumbnailFile
 from pyams_utils.interfaces.tales import ITALESExtension
 from zope.traversing.interfaces import ITraversable
 
@@ -45,7 +45,7 @@
 THUMB_SIZE = re.compile('^(?:\w+\:)?([0-9]+)x([0-9]+)$')
 
 
-@adapter_config(context=IImage, provides=IThumbnail)
+@adapter_config(context=IImage, provides=IThumbnails)
 class ImageThumbnailAdapter(object):
     """Image thumbnails adapter"""
 
@@ -217,7 +217,7 @@
 
 @subscriber(IFileModifiedEvent, context_selector=IImage)
 def handle_modified_file(event):
-    thumbnail = IThumbnail(event.object)
+    thumbnail = IThumbnails(event.object)
     thumbnail.clear_geometries()
     thumbnail.clear_thumbnails()
 
@@ -232,12 +232,12 @@
         else:
             thumbnail_name = name
             format = None
-        thumbnails = IThumbnail(self.context)
+        thumbnails = IThumbnails(self.context)
         if ':' in thumbnail_name:
             selection_name, thumbnail_name = thumbnail_name.split(':', 1)
             selection = thumbnails.get_selection(selection_name, format)
             transaction.commit()
-            thumbnails = IThumbnail(selection)
+            thumbnails = IThumbnails(selection)
         result = thumbnails.get_thumbnail(thumbnail_name, format)
         transaction.commit()
         return result
@@ -253,7 +253,7 @@
     def render(self, context=None):
         if context is None:
             context = self.context
-        return IThumbnail(context, None)
+        return IThumbnails(context, None)
 
 
 @adapter_config(name='thumbnail', context=(Interface, Interface, Interface), provides=ITALESExtension)
--- a/src/pyams_file/widget/__init__.py	Mon Jul 02 17:13:55 2018 +0200
+++ b/src/pyams_file/widget/__init__.py	Thu Jul 05 15:02:24 2018 +0200
@@ -20,7 +20,7 @@
 
 # import interfaces
 from pyams_file.interfaces import IFileField, IFileWidget, IMediaField, IMediaWidget, \
-    IThumbnailMediaField, IThumbnailMediaWidget, DELETED_FILE, IThumbnail
+    IThumbnailMediaField, IThumbnailMediaWidget, DELETED_FILE, IThumbnails
 from pyams_form.interfaces.form import IFormLayer
 from pyramid.interfaces import IView
 from z3c.form.interfaces import NOT_CHANGED, IFieldWidget, IDataConverter
@@ -106,7 +106,7 @@
         return get_human_size(value, self.request)
 
     def get_thumbnail(self, geometry='128x128'):
-        thumbnails = IThumbnail(self.current_value, None)
+        thumbnails = IThumbnails(self.current_value, None)
         if thumbnails is not None:
             display = thumbnails.get_thumbnail(geometry)
             if display is not None:
--- a/src/pyams_file/zmi/image.py	Mon Jul 02 17:13:55 2018 +0200
+++ b/src/pyams_file/zmi/image.py	Thu Jul 05 15:02:24 2018 +0200
@@ -21,7 +21,7 @@
 from collections import OrderedDict
 
 # import interfaces
-from pyams_file.interfaces import IImage, IThumbnail, IResponsiveImage, IFileModifierForm, IThumbnailer, \
+from pyams_file.interfaces import IImage, IThumbnails, IResponsiveImage, IFileModifierForm, IThumbnailer, \
     IFileInfo, IThumbnailForm, IMediaWidget, ISVGImage
 from pyams_form.interfaces.form import IWidgetsPrefixViewletsManager, IFormHelp
 from pyams_i18n.interfaces import II18n
@@ -73,7 +73,7 @@
 def render_img(image, width=None, height=None, request=None, css_class='', timestamp=False):
     """Render image thumbnail"""
     thumbnail = None
-    thumbnails = IThumbnail(image, None)
+    thumbnails = IThumbnails(image, None)
     if thumbnails is not None:
         if width or height:
             thumbnail = thumbnails.get_thumbnail('{0}x{1}'.format(width, height))
@@ -132,7 +132,7 @@
     # Commit to save blobs!!
     ITransactionManager(image).commit()
     cache_key = ICacheKeyValue(image)
-    thumbnail = IThumbnail(image).get_thumbnail('128x128')
+    thumbnail = IThumbnails(image).get_thumbnail('128x128')
     dc = IZopeDublinCore(thumbnail)
     return {
         'status': 'success',
@@ -283,7 +283,7 @@
         geometry.y1 = int(self.request.params.get('selection.y1'))
         geometry.x2 = int(self.request.params.get('selection.x2'))
         geometry.y2 = int(self.request.params.get('selection.y2'))
-        IThumbnail(self.context).set_geometry(self.selection_name, geometry)
+        IThumbnails(self.context).set_geometry(self.selection_name, geometry)
 
     def get_ajax_output(self, changes):
         return {
@@ -638,11 +638,11 @@
         adapters = sorted(registry.getAdapters((self.context, ), IThumbnailer),
                           key=lambda x: x[1].weight)
         for name, adapter in adapters:
-            thumbnails = IThumbnail(self.context)
+            thumbnails = IThumbnails(self.context)
             if name:
                 selection = thumbnails.get_selection(name)
                 transaction.commit()
-                thumbnails = IThumbnail(selection)
+                thumbnails = IThumbnails(selection)
             thumbnail = thumbnails.get_thumbnail('200x128')
             thumbnailers.setdefault(translate(adapter.section), []).append({'name': name,
                                                                             'label': translate(adapter.label),