[Erp5-report] r37801 nicolas - /erp5/trunk/products/ERP5/mixin/downloadable.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Aug 13 15:54:53 CEST 2010


Author: nicolas
Date: Fri Aug 13 15:54:48 2010
New Revision: 37801

URL: http://svn.erp5.org?rev=37801&view=rev
Log:
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.

Modified:
    erp5/trunk/products/ERP5/mixin/downloadable.py

Modified: erp5/trunk/products/ERP5/mixin/downloadable.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/mixin/downloadable.py?rev=37801&r1=37800&r2=37801&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/mixin/downloadable.py [utf8] (original)
+++ erp5/trunk/products/ERP5/mixin/downloadable.py [utf8] Fri Aug 13 15:54:48 2010
@@ -32,13 +32,15 @@ from Products.ERP5Type.Utils import fill
 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)




More information about the Erp5-report mailing list