1111from Products .CMFCore .utils import getToolByName
1212from Products .CMFPlone .utils import safe_unicode
1313from zope import i18n
14+ from zope .annotation import IAnnotations
1415from zope .component import getMultiAdapter
1516from zope .component .hooks import getSite
1617from 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