[Erp5-report] r32926 nicolas.dumazet - in /erp5/trunk/products/ERP5: Document/ Tool/

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Feb 22 11:18:37 CET 2010


Author: nicolas.dumazet
Date: Mon Feb 22 11:18:37 2010
New Revision: 32926

URL: http://svn.erp5.org?rev=32926&view=rev
Log:
Do not export or import non-existing properties of BT objects.

Example of bad behavior:
 - "short_title" property is not used / has no associated field
 - in export code getProperty('short_title') returns None
 - and a bt/short_title file is created, containing str(None)
 - when reimporting this BT, bt/short_title is read, and obj.short_title is set
    to 'None' string
 - as a result, bt.getShortTitle() wrongly returns "None" _string_


Modified:
    erp5/trunk/products/ERP5/Document/BusinessTemplate.py
    erp5/trunk/products/ERP5/Tool/TemplateTool.py

Modified: erp5/trunk/products/ERP5/Document/BusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessTemplate.py?rev=32926&r1=32925&r2=32926&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] Mon Feb 22 11:18:37 2010
@@ -5553,6 +5553,8 @@
                   'install_object_list_list', 'id_generator', 'bt_for_diff'):
           continue
         value = self.getProperty(id)
+        if value is None:
+          continue
         if prop_type in ('text', 'string', 'int', 'boolean'):
           bta.addObject(obj=value, name=id, path=path+os.sep+'bt', ext='')
         elif prop_type in ('lines', 'tokens'):

Modified: erp5/trunk/products/ERP5/Tool/TemplateTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/TemplateTool.py?rev=32926&r1=32925&r2=32926&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/TemplateTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Tool/TemplateTool.py [utf8] Mon Feb 22 11:18:37 2010
@@ -256,6 +256,11 @@
             except KeyError:
               continue
             value = tar.extractfile(info).read()
+            if value is 'None':
+              # At export time, we used to export non-existent properties:
+              #   str(obj.getProperty('non-existing')) == 'None'
+              # Discard them
+              continue
             if prop_type == 'text' or prop_type == 'string' \
                                    or prop_type == 'int':
               prop_dict[pid] = value
@@ -320,6 +325,11 @@
           if not os.path.exists(prop_path):
             continue          
           value = open(prop_path, 'rb').read()
+          if value is 'None':
+            # At export time, we used to export non-existent properties:
+            #   str(obj.getProperty('non-existing')) == 'None'
+            # Discard them
+            continue
           if prop_type in ('text', 'string', 'int', 'boolean'):
             prop_dict[pid] = value
           elif prop_type in ('lines', 'tokens'):




More information about the Erp5-report mailing list