Commit c711c004 authored by Nicolas Delaby's avatar Nicolas Delaby

Use explicitely downloadable_mixin for consistency


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35231 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2856d229
...@@ -187,7 +187,6 @@ class File(Document, CMFFile): ...@@ -187,7 +187,6 @@ class File(Document, CMFFile):
CMFFile.PUT(self, REQUEST, RESPONSE) CMFFile.PUT(self, REQUEST, RESPONSE)
# DAV Support # DAV Support
index_html = CMFFile.index_html
PUT = CMFFile.PUT PUT = CMFFile.PUT
security.declareProtected('FTP access', 'manage_FTPget', 'manage_FTPstat', 'manage_FTPlist') security.declareProtected('FTP access', 'manage_FTPget', 'manage_FTPstat', 'manage_FTPlist')
manage_FTPget = CMFFile.manage_FTPget manage_FTPget = CMFFile.manage_FTPget
......
...@@ -360,31 +360,13 @@ class Image(File, OFSImage): ...@@ -360,31 +360,13 @@ class Image(File, OFSImage):
# Display # Display
security.declareProtected('View', 'index_html') security.declareProtected('View', 'index_html')
def index_html(self, REQUEST, RESPONSE, display=None, format='', quality=75, def index_html(self, REQUEST, RESPONSE, format=None, display=None,
resolution=None, frame=None): quality=DEFAULT_QUALITY, resolution=None, frame=None, **kw):
"""Return the image data.""" """Return the image data."""
self._upradeImage() self._upradeImage()
return Document.index_html(self, REQUEST, RESPONSE, format=format,
# display may be set from a cookie (?) display=display, quality=quality, resolution=resolution,
image_size = self.getSizeFromImageDisplay(display) frame=frame, **kw)
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)
# #
# Photo processing # Photo processing
......
...@@ -69,34 +69,6 @@ class PDFDocument(Image, CachedConvertableMixin): ...@@ -69,34 +69,6 @@ class PDFDocument(Image, CachedConvertableMixin):
'version', 'short_title', 'version', 'short_title',
'subject', 'source_reference', 'source_project_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 # Conversion API
security.declareProtected(Permissions.AccessContentsInformation, 'convert') security.declareProtected(Permissions.AccessContentsInformation, 'convert')
def convert(self, format, **kw): def convert(self, format, **kw):
......
...@@ -126,27 +126,6 @@ class TextDocument(Document, TextContent): ...@@ -126,27 +126,6 @@ class TextDocument(Document, TextContent):
security.declareProtected( Permissions.ModifyPortalContent, 'edit' ) security.declareProtected( Permissions.ModifyPortalContent, 'edit' )
edit = WorkflowMethod( _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): def _substituteTextContent(self, text, safe_substitute=True, **kw):
# If a method for string substitutions of the text content, perform it. # If a method for string substitutions of the text content, perform it.
# Decode everything into unicode before the substitutions, in order to # Decode everything into unicode before the substitutions, in order to
......
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