[Checkins] SVN: zopyx.smartprintng.core/trunk/zopyx/smartprintng/core/renderer.py moved image handling at the end of the renderer in order to support

Andreas Jung andreas at andreas-jung.com
Sun Oct 19 05:35:11 EDT 2008


Log message for revision 92374:
  moved image handling at the end of the renderer in order to support
  images within render templates
  

Changed:
  U   zopyx.smartprintng.core/trunk/zopyx/smartprintng/core/renderer.py

-=-
Modified: zopyx.smartprintng.core/trunk/zopyx/smartprintng/core/renderer.py
===================================================================
--- zopyx.smartprintng.core/trunk/zopyx/smartprintng/core/renderer.py	2008-10-19 09:10:21 UTC (rev 92373)
+++ zopyx.smartprintng.core/trunk/zopyx/smartprintng/core/renderer.py	2008-10-19 09:35:11 UTC (rev 92374)
@@ -103,8 +103,11 @@
 
         # Download remote images and make them local 
         # ATT: handling of local images
-        soup = self.makeImagesLocal(soup)
+        # moved code to the end of the pipline because
+        # the render template might also contain images
+        # soup = self.makeImagesLocal(soup)
 
+
         # now pass the modified HTML fragment to the template
         # in order to render a proper HTML document
         html2 = soup.renderContents()
@@ -123,6 +126,13 @@
         rendered_html = template(**params)
         if beautify_html:
             rendered_html = BeautifulSoup(rendered_html).prettify()
+
+        # Download remote images and make them local 
+        # ATT: handling of local images
+        soup2 = BeautifulSoup(rendered_html)    
+        soup2 = self.makeImagesLocal(soup2)
+        rendered_html = soup2.renderContents()
+        
         self.rendered_html = rendered_html
         return self.rendered_html
 
@@ -176,3 +186,4 @@
         pil_img.save(new_img_path, 'PNG')
         del pil_img
         LOG.debug('Image %s stored as %s' % (src, new_img_path))
+        return new_img_path



More information about the Checkins mailing list