Ticket #1839 (closed enhancement: fixed)

Opened 2 years ago

Last modified 2 years ago

Creating images with CPSDocument.createFile

Reported by: mschulz@WEBGIS.DE Assigned to: madarche
Priority: P2 Milestone: CPS 3.4.5
Component: CPS (global) Version: TRUNK
Severity: normal Keywords:
Cc:

Description

createFile.py always creates Zope file objects, even if you upload images, a zope file object is created. This patch creates image objects (the diff comes from CPS Version 3.4.3):

--- ../Products-CPS-platform-3.4.3/CPSDocument/createFile.py  2007-04-10
10:52:10.000000000 +0200
+++ createFile.py 2007-04-12 14:07:08.000000000 +0200
@@ -25,7 +25,7 @@
 from logging import getLogger

 from Products.CMFCore.utils import getToolByName
-from OFS.Image import File
+from OFS.Image import File, Image
 from AccessControl import ModuleSecurityInfo
 from zipfile import ZipFile, BadZipfile
 from StringIO import StringIO
@@ -107,7 +107,10 @@

        # create file to attach to document
        data = zipfile.read(path)
-        file_to_attach = File(path_filename, path_filename, data)
+        if ptype in ['Image']:
+            file_to_attach = Image(path_filename, path_filename, data)
+        else:
+            file_to_attach = File(path_filename, path_filename, data)
        if mimetype and file_to_attach.content_type != mimetype:
            logger.debug('Fixing mimetype from %s to %s',
                         file_to_attach.content_type, mimetype)

Change History

04/30/07 12:11:13 changed by tracguest

There is another addition to be found in the lists, that enables createFile to keep the directory structure of a zip-file: http://lists.nuxeo.com/pipermail/cps-devel/2007-March/003243.html

Cheers, Michael Schulz

05/02/07 18:47:59 changed by madarche

  • reporter changed from tracguest to mschulz@WEBGIS.DE.

05/02/07 18:48:46 changed by madarche

Related to #1840.

05/02/07 18:54:12 changed by madarche

What advantages does your patch provide please ? Please provide a use case.

05/10/07 17:31:54 changed by mschulz@webgis.de

One advantage is that an image object knows about its dimensions in the width/height properties.

05/15/07 17:25:49 changed by madarche

Thanks for the patch!

Fixed with changeset [51746].

05/22/07 17:50:24 changed by madarche

  • status changed from new to closed.
  • resolution set to fixed.