[Erp5-report] r35231 nicolas - /erp5/trunk/products/ERP5/Document/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed May 12 17:07:22 CEST 2010


Author: nicolas
Date: Wed May 12 17:07:19 2010
New Revision: 35231

URL: http://svn.erp5.org?rev=35231&view=rev
Log:
Use explicitely downloadable_mixin for consistency

Modified:
    erp5/trunk/products/ERP5/Document/Image.py
    erp5/trunk/products/ERP5/Document/PDFDocument.py
    erp5/trunk/products/ERP5/Document/TextDocument.py

Modified: erp5/trunk/products/ERP5/Document/Image.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/Image.py?rev=35231&r1=35230&r2=35231&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/Image.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/Image.py [utf8] Wed May 12 17:07:19 2010
@@ -360,31 +360,13 @@
 
   # 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

Modified: erp5/trunk/products/ERP5/Document/PDFDocument.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/PDFDocument.py?rev=35231&r1=35230&r2=35231&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/PDFDocument.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/PDFDocument.py [utf8] Wed May 12 17:07:19 2010
@@ -68,34 +68,6 @@
   searchable_property_list = ('asText', 'title', 'description', 'id', 'reference',
                               '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')

Modified: erp5/trunk/products/ERP5/Document/TextDocument.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/TextDocument.py?rev=35231&r1=35230&r2=35231&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/TextDocument.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/TextDocument.py [utf8] Wed May 12 17:07:19 2010
@@ -125,27 +125,6 @@
 
     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.




More information about the Erp5-report mailing list