Skip to content

Commit 5c49e97

Browse files
committed
Added original file in annotation
1 parent 6dcdb02 commit 5c49e97

File tree

1 file changed

+9
-2
lines changed
  • src/collective/documentgenerator

1 file changed

+9
-2
lines changed

src/collective/documentgenerator/utils.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from Products.CMFCore.utils import getToolByName
1212
from Products.CMFPlone.utils import safe_unicode
1313
from zope import i18n
14+
from zope.annotation import IAnnotations
1415
from zope.component import getMultiAdapter
1516
from zope.component.hooks import getSite
1617
from zope.component.hooks import setSite
@@ -266,7 +267,8 @@ def convert_odt(afile, output_name, fmt='pdf', **kwargs):
266267
return output_name, converted_file
267268

268269

269-
def convert_and_save_odt(afile, container, portal_type, output_name, fmt='pdf', attributes=None, **kwargs):
270+
def convert_and_save_odt(afile, container, portal_type, output_name, fmt='pdf', from_uid=None, attributes=None,
271+
**kwargs):
270272
"""
271273
Convert an odt file to another format using appy.pod and save it in a NamedBlobFile.
272274
@@ -275,16 +277,21 @@ def convert_and_save_odt(afile, container, portal_type, output_name, fmt='pdf',
275277
:param portal_type: portal type
276278
:param output_name: output name
277279
:param fmt: output format, default to 'pdf'
280+
:param from_uid: uid from original file object
278281
:param attributes: dict of other attributes to set on created content
279282
:param kwargs: other parameters passed to Renderer, i.e pdfOptions='ExportNotes=True;SelectPdfVersion=1'
280283
"""
281284
converted_filename, converted_file = convert_odt(afile, output_name, fmt=fmt, **kwargs)
282285
file_object = NamedBlobFile(converted_file, filename=safe_unicode(converted_filename))
283286
if attributes is None:
284287
attributes = {}
285-
return createContentInContainer(
288+
new_file = createContentInContainer(
286289
container,
287290
portal_type,
288291
title=converted_filename,
289292
file=file_object,
290293
**attributes)
294+
if from_uid:
295+
annot = IAnnotations(new_file)
296+
annot["documentgenerator"] = {"conv_from_uid": from_uid}
297+
return new_file

0 commit comments

Comments
 (0)