Added optional "source" argument to image JSON refresh event
authorThierry Florac <thierry.florac@onf.fr>
Thu, 20 Sep 2018 15:02:44 +0200
changeset 406 0ceaf5ebca1c
parent 405 21c50bf81344
child 407 9313280dd95f
Added optional "source" argument to image JSON refresh event
src/pyams_skin/event.py
--- a/src/pyams_skin/event.py	Thu Sep 20 14:33:21 2018 +0200
+++ b/src/pyams_skin/event.py	Thu Sep 20 15:02:44 2018 +0200
@@ -30,16 +30,17 @@
     }
 
 
-def get_json_image_refresh_event(image, request):
+def get_json_image_refresh_event(image, request, source=None):
     """Get JSON response for image refresh event"""
     dc = IZopeDublinCore(image)
-    source = absolute_url(image, request)
+    src = absolute_url(image if source is None else source, request)
+    target = absolute_url(image, request)
     return {
         'event': 'myams.refresh',
         'options': {
             'handler': 'MyAMS.skin.refreshImage',
-            'src': source,
-            'target': '{0}?_={1}'.format(source, dc.modified.timestamp())
+            'src': src,
+            'target': '{0}?_={1}'.format(target, dc.modified.timestamp())
         }
     }