Commit 67ed6848 authored by Ivan Tyagov's avatar Ivan Tyagov

Downloadables should accept 'display', 'quality', 'resolution', 'frame' (it's...

Downloadables should accept 'display', 'quality', 'resolution', 'frame' (it's job of implementation to  honour or not them). Resize image produced from Web Page to Image conversion.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43335 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4a578f68
......@@ -36,6 +36,8 @@ from Products.ERP5.Document.Document import Document, ConversionError, _MARKER,
from Products.ERP5.Document.File import File
from Products.ERP5Type.WebDAVSupport import TextContent
import re
from Products.ERP5.Document.Document import VALID_IMAGE_FORMAT_LIST
import cStringIO
# Mixin Import
from Products.ERP5.mixin.cached_convertable import CachedConvertableMixin
......@@ -166,6 +168,16 @@ class TextDocument(CachedConvertableMixin, BaseConvertableFileMixin,
'portal_transforms failed to convert '
'from %r to %s: %r' %
(src_mimetype, mime_type, self))
if format in VALID_IMAGE_FORMAT_LIST:
# do resize by temporary image
temp_image = self.portal_contributions.newContent(
portal_type='Image',
file=cStringIO.StringIO(),
filename=self.getId(),
temp_object=1)
temp_image._setData(result)
mime, result = temp_image.convert(**kw)
self.setConversion(result, original_mime_type, **kw)
else:
mime_type, result = self.getConversion(**kw)
......
......@@ -40,7 +40,7 @@ class DownloadableMixin:
### Content processing methods
security.declareProtected(Permissions.View, 'index_html')
@fill_args_from_request
@fill_args_from_request('display', 'quality', 'resolution', 'frame')
def index_html(self, REQUEST, RESPONSE, format=_MARKER, **kw):
"""
We follow here the standard Zope API for files and images
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment