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):
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
......
......@@ -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
......
......@@ -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):
......
......@@ -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
......
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