Pre-locate medias before setting data to enable medias conversion
authorThierry Florac <tflorac@ulthar.net>
Wed, 07 Feb 2018 11:50:51 +0100
changeset 365 e956535074d3
parent 364 b2fc446f15d9
child 366 9daa8a31a58d
Pre-locate medias before setting data to enable medias conversion
src/pyams_content/component/gallery/zmi/file.py
--- a/src/pyams_content/component/gallery/zmi/file.py	Wed Feb 07 11:49:55 2018 +0100
+++ b/src/pyams_content/component/gallery/zmi/file.py	Wed Feb 07 11:50:51 2018 +0100
@@ -46,6 +46,7 @@
 from pyramid.view import view_config
 from z3c.form import field
 from zope.lifecycleevent import ObjectCreatedEvent
+from zope.location import locate
 
 from pyams_content import _
 
@@ -97,6 +98,7 @@
                 for content, filename in extractor.get_contents():
                     try:
                         media = GalleryFile()
+                        locate(media, self.context)
                         media.data = filename, content
                     except WrongType:
                         continue
@@ -106,6 +108,7 @@
             else:
                 try:
                     media = GalleryFile()
+                    locate(media, self.context)
                     media.data = filename, medias_data if filename else medias_data
                 except WrongType:
                     pass