Commit a5f5bc78 authored by Nicolas Delaby's avatar Nicolas Delaby

All Documents shared the same downloading behaviour

The rules are.
  A document is always returned in erp5 environment mode,
  except if conversion parameters are passed like format, display, ... 
  or a special method is called like asStrippedHTML, Base_download, ...

  All links to an image must be written with a conversion parameter in its url:
    http://www.example.com/REFERENCE.TO.IMAGE?format=png 
 or http://www.example.com/REFERENCE.TO.IMAGE?display=small
  An example with a method:
    http://www.example.com/REFERENCE.TO.TEXT/asStrippedHTML
 or http://www.example.com/REFERENCE.TO.IMAGE/Base_download

path like http://www.example.com/REFERENCE.TO.IMAGE and http://www.example.com/REFERENCE.TO.IMAGE/view
returns the same result and are fully consistent among all document types.

manage_FTPget is overrided to force the download of raw content for WebDav and FTP access.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37801 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f193c118
......@@ -32,13 +32,15 @@ from Products.ERP5Type.Utils import fill_args_from_request
from Products.CMFCore.utils import getToolByName, _setCacheHeaders,\
_ViewEmulator
_MARKER = []
class DownloadableMixin:
security = ClassSecurityInfo()
### Content processing methods
security.declareProtected(Permissions.View, 'index_html')
@fill_args_from_request
def index_html(self, REQUEST, RESPONSE, format=None, **kw):
def index_html(self, REQUEST, RESPONSE, format=_MARKER, **kw):
"""
We follow here the standard Zope API for files and images
and extend it to support format conversion. The idea
......@@ -64,9 +66,15 @@ class DownloadableMixin:
from Products.ERP5.Document.Document import VALID_TEXT_FORMAT_LIST,\
VALID_IMAGE_FORMAT_LIST
web_cache_kw = kw.copy()
web_cache_kw['format'] = format
if format is not _MARKER:
web_cache_kw['format'] = format
_setCacheHeaders(_ViewEmulator().__of__(self), web_cache_kw)
if format is _MARKER and not kw:
# conversion parameters is mandatory to download the converted content.
# By default allways return view action.
# for all WevDAV access return raw content.
return self.view()
self._checkConversionFormatPermission(format, **kw)
mime, data = self.convert(format, **kw)
if not format:
......@@ -104,3 +112,10 @@ class DownloadableMixin:
method = self._getTypeBasedMethod('getStandardFileName',
fallback_script_id='Document_getStandardFileName')
return method(format=format)
def manage_FTPget(self):
"""Return body for ftp. and WebDAV
"""
# pass format argument to force downloading raw content
REQUEST = self.REQUEST
return self.index_html(REQUEST, REQUEST.RESPONSE, format=None)
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