From c711c004f23aa8f5f19a09ba31a2b8be0fa9d3ba Mon Sep 17 00:00:00 2001 From: Nicolas Delaby <nicolas@nexedi.com> Date: Wed, 12 May 2010 15:07:19 +0000 Subject: [PATCH] Use explicitely downloadable_mixin for consistency git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35231 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/File.py | 1 - product/ERP5/Document/Image.py | 28 +++++---------------------- product/ERP5/Document/PDFDocument.py | 28 --------------------------- product/ERP5/Document/TextDocument.py | 21 -------------------- 4 files changed, 5 insertions(+), 73 deletions(-) diff --git a/product/ERP5/Document/File.py b/product/ERP5/Document/File.py index 1b07fbd205..b398fbc3f5 100644 --- a/product/ERP5/Document/File.py +++ b/product/ERP5/Document/File.py @@ -187,7 +187,6 @@ class File(Document, CMFFile): CMFFile.PUT(self, REQUEST, RESPONSE) # DAV Support - index_html = CMFFile.index_html PUT = CMFFile.PUT security.declareProtected('FTP access', 'manage_FTPget', 'manage_FTPstat', 'manage_FTPlist') manage_FTPget = CMFFile.manage_FTPget diff --git a/product/ERP5/Document/Image.py b/product/ERP5/Document/Image.py index ba1065ec2d..8dc606b053 100644 --- a/product/ERP5/Document/Image.py +++ b/product/ERP5/Document/Image.py @@ -360,31 +360,13 @@ class Image(File, OFSImage): # Display security.declareProtected('View', 'index_html') - def index_html(self, REQUEST, RESPONSE, display=None, format='', quality=75, - resolution=None, frame=None): + def index_html(self, REQUEST, RESPONSE, format=None, display=None, + quality=DEFAULT_QUALITY, resolution=None, frame=None, **kw): """Return the image data.""" self._upradeImage() - - # display may be set from a cookie (?) - image_size = self.getSizeFromImageDisplay(display) - kw = dict(display=display, format=format, quality=quality, - resolution=resolution, frame=frame, image_size=image_size) - _setCacheHeaders(_ViewEmulator().__of__(self), kw) - - if (display is not None or resolution is not None or quality != 75 or format != ''\ - or frame is not None) and image_size: - try: - mime, image = self.getConversion(**kw) - except KeyError: - # Generate photo on-the-fly - mime, image = self._makeDisplayPhoto(**kw) - self.setConversion(image, mime, **kw) - RESPONSE.setHeader('Content-Type', mime) - return image.index_html(REQUEST, RESPONSE) - - # Return original image - return OFSImage.index_html(self, REQUEST, RESPONSE) - + return Document.index_html(self, REQUEST, RESPONSE, format=format, + display=display, quality=quality, resolution=resolution, + frame=frame, **kw) # # Photo processing diff --git a/product/ERP5/Document/PDFDocument.py b/product/ERP5/Document/PDFDocument.py index 1b2c5177aa..6c915d467d 100644 --- a/product/ERP5/Document/PDFDocument.py +++ b/product/ERP5/Document/PDFDocument.py @@ -69,34 +69,6 @@ class PDFDocument(Image, CachedConvertableMixin): 'version', 'short_title', 'subject', 'source_reference', 'source_project_title',) - security.declareProtected(Permissions.View, 'index_html') - def index_html(self, REQUEST, RESPONSE, display=None, format='', quality=75, - resolution=None, frame=0): - """ - Returns data in the appropriate format (graphical) - it is always a zip because multi-page pdfs are converted into a zip - file of many images - """ - _setCacheHeaders(_ViewEmulator().__of__(self), {'format' : format}) - if format is '': - if self.getSourceReference() is not None: - filename = self.getSourceReference() - else: - filename = self.getId() - RESPONSE.setHeader('Content-Disposition', - 'attachment; filename="%s"' % filename) - RESPONSE.setHeader('Content-Type', 'application/pdf') - return str(self.data) - if format in ('html', 'txt', 'text'): - mime, data = self.convert(format) - RESPONSE.setHeader('Content-Length', len(data)) - RESPONSE.setHeader('Content-Type', '%s;charset=UTF-8' % mime) - RESPONSE.setHeader('Accept-Ranges', 'bytes') - return data - return Image.index_html(self, REQUEST, RESPONSE, display=display, - format=format, quality=quality, - resolution=resolution, frame=frame) - # Conversion API security.declareProtected(Permissions.AccessContentsInformation, 'convert') def convert(self, format, **kw): diff --git a/product/ERP5/Document/TextDocument.py b/product/ERP5/Document/TextDocument.py index 56fad6da24..1f6787eb8e 100644 --- a/product/ERP5/Document/TextDocument.py +++ b/product/ERP5/Document/TextDocument.py @@ -126,27 +126,6 @@ class TextDocument(Document, TextContent): security.declareProtected( Permissions.ModifyPortalContent, 'edit' ) edit = WorkflowMethod( _edit ) - # Default Display - security.declareProtected(Permissions.View, 'index_html') - def index_html(self, REQUEST, RESPONSE, format=None, **kw): - """ - Unlike for images and files, we want to provide - in the case of HTML a nice standard display with - all the layout of a Web Site. If no format is provided, - the default rendering will use the standard ERP5 machinery. - By providing a format parameter, it is possible to - convert the text content into various formats. - """ - if format is None: - # The default is to use ERP5 Forms to render the page - return self.view() - mime, data = self.convert(format=format) - RESPONSE.setHeader('Content-Length', len(str(data))) # XXX - Not efficient - # if datastream instance - RESPONSE.setHeader('Content-Type', mime) - RESPONSE.setHeader('Accept-Ranges', 'bytes') - return data - def _substituteTextContent(self, text, safe_substitute=True, **kw): # If a method for string substitutions of the text content, perform it. # Decode everything into unicode before the substitutions, in order to -- 2.30.9