From da03f209e3521f25741bfbd27acfb23ec5809c50 Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Tue, 23 Nov 2010 09:13:56 +0000
Subject: [PATCH] Simplification of boolean evaluation: bool({}) == False Fix
 default values for some dictionaries.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@40513 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/ImageField.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/product/ERP5Form/ImageField.py b/product/ERP5Form/ImageField.py
index 7a8c4b1108..9023d672ab 100644
--- a/product/ERP5Form/ImageField.py
+++ b/product/ERP5Form/ImageField.py
@@ -169,21 +169,21 @@ class ImageFieldWidget(Widget.TextWidget):
         if (image_object.getWidth(), image_object.getHeight()) not in \
           ((-1, -1), (0,0)):
           width, height = image_object._getAspectRatioSize(width, height)
-          if draw_frame_node.attrib.get('{%s}width' % SVG_URI, {}) != {} and \
-          draw_frame_node.attrib.get('{%s}height' % SVG_URI, {}) != {}:
+          if draw_frame_node.attrib.get('{%s}width' % SVG_URI) and \
+            draw_frame_node.attrib.get('{%s}height' % SVG_URI):
             # if a size already exist from attr_dict, try to resize the image to
             # fit this size (image should not be biger than size from attr_dict)
             # devide the value by 20 to have cm instead of px
             width, height = self._getPictureSize(width/20., height/20.,
-                target_width=draw_frame_node.attrib.get('{%s}width' % SVG_URI, {}),
-                target_height=draw_frame_node.attrib.get('{%s}height' % SVG_URI, {}))
+                target_width=draw_frame_node.attrib.get('{%s}width' % SVG_URI, ''),
+                target_height=draw_frame_node.attrib.get('{%s}height' % SVG_URI, ''))
 
           draw_frame_node.set('{%s}width' % SVG_URI, str(width))
           draw_frame_node.set('{%s}height' % SVG_URI, str(height))
 
       image_tag_name = '{%s}%s' % (DRAW_URI, 'image')
       image_node = Element(image_tag_name, nsmap=NSMAP)
-      image_node.attrib.update(attr_dict.get(image_tag_name, {}).pop())
+      image_node.attrib.update(attr_dict.get(image_tag_name, []).pop())
       image_node.set('{%s}href' % XLINK_URI, picture_path)
 
       draw_frame_node.append(image_node)
-- 
2.30.9