[Erp5-report] r31646 fabien - in /erp5/trunk/products/ERP5/bootstrap/erp5_core: SkinTemplat...

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Jan 7 17:16:07 CET 2010


Author: fabien
Date: Thu Jan  7 17:16:04 2010
New Revision: 31646

URL: http://svn.erp5.org?rev=31646&view=rev
Log:
translate string that were not, and fix a bug that make listboxes crash in some cases :

In case of binary modification, the history tab of listboxes try to display diff between binary data, but it fails because binary data can't be converted to unicode. Now a message "Binary data can't be displayed" is display instead and the listbox don't crash for this reason.

Modified:
    erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonDifferenceList.xml
    erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonDifferenceList.xml
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonDifferenceList.xml?rev=31646&r1=31645&r2=31646&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonDifferenceList.xml [utf8] (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getHistoricalComparisonDifferenceList.xml [utf8] Thu Jan  7 17:16:04 2010
@@ -55,6 +55,7 @@
             <key> <string>_body</string> </key>
             <value> <string>from Products.PythonScripts.standard import Object\n
 from ZODB.POSException import ConflictError\n
+Base_translateString = context.Base_translateString\n
 \n
 serial = context.REQUEST[\'serial\']\n
 next_serial = context.REQUEST[\'next_serial\']\n
@@ -64,8 +65,8 @@
 except ConflictError:\n
   raise\n
 except: # POSKeyError\n
-  return [Object(property_name=\'Historical revisions are not available, \'\n
-                               \'maybe the database has been packed\')]\n
+  return [Object(property_name=Base_translateString(\'Historical revisions are\'\n
+                      \' not available, maybe the database has been packed\'))]\n
 \n
 if next_serial == \'0.0.0.0\':\n
   new_getProperty = context.getProperty\n
@@ -75,15 +76,35 @@
 old = context.HistoricalRevisions[serial]\n
 result = []\n
 \n
+binary_data_explanation = Base_translateString("Binary data can\'t be displayed")\n
+\n
 for prop_dict in context.getPropertyMap():\n
   prop = prop_dict[\'id\']\n
+  current_value=context.getProperty(prop)\n
   old_value = old.getProperty(prop)\n
   new_value = new_getProperty(prop)\n
   if new_value != old_value:\n
+    # check if values are unicode convertible (binary are not)\n
+    if isinstance(new_value, (str, unicode)):\n
+      try:\n
+        unicode(str(new_value), \'utf-8\')\n
+      except UnicodeDecodeError:\n
+        new_value = binary_data_explanation\n
+    if isinstance(old_value, (str, unicode)):\n
+      try:\n
+        unicode(str(old_value), \'utf-8\')\n
+      except UnicodeDecodeError:\n
+        old_value = binary_data_explanation\n
+    if isinstance(current_value, (str, unicode)):\n
+      try:\n
+        unicode(str(current_value), \'utf-8\')\n
+      except UnicodeDecodeError:\n
+        current_value = binary_data_explanation\n
+\n
     result.append( Object( property_name=prop,\n
                            new_value=new_value,\n
                            old_value=old_value,\n
-                           current_value=context.getProperty(prop)))\n
+                           current_value=current_value))\n
 return result\n
 </string> </value>
         </item>
@@ -126,20 +147,27 @@
                             <string>Object</string>
                             <string>ZODB.POSException</string>
                             <string>ConflictError</string>
-                            <string>_getitem_</string>
                             <string>_getattr_</string>
                             <string>context</string>
+                            <string>Base_translateString</string>
+                            <string>_getitem_</string>
                             <string>serial</string>
                             <string>next_serial</string>
                             <string>new_getProperty</string>
                             <string>new</string>
                             <string>old</string>
                             <string>result</string>
+                            <string>binary_data_explanation</string>
                             <string>_getiter_</string>
                             <string>prop_dict</string>
                             <string>prop</string>
+                            <string>current_value</string>
                             <string>old_value</string>
                             <string>new_value</string>
+                            <string>isinstance</string>
+                            <string>str</string>
+                            <string>unicode</string>
+                            <string>UnicodeDecodeError</string>
                           </tuple>
                         </value>
                     </item>

Modified: erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision?rev=31646&r1=31645&r2=31646&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision [utf8] (original)
+++ erp5/trunk/products/ERP5/bootstrap/erp5_core/bt/revision [utf8] Thu Jan  7 17:16:04 2010
@@ -1,1 +1,1 @@
-1420
+1422




More information about the Erp5-report mailing list