[Erp5-report] r22309 - /erp5/trunk/products/ERP5Type/Base.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Jul 7 13:44:26 CEST 2008


Author: seb
Date: Mon Jul  7 13:44:24 2008
New Revision: 22309

URL: http://svn.erp5.org?rev=22309&view=rev
Log:
Patch proposed by Jean-Paul,
_getDefaultAcquiredProperty was not handling well 
getDefault[Property of type List] when there is not
an acquisition object id.

Modified:
    erp5/trunk/products/ERP5Type/Base.py

Modified: erp5/trunk/products/ERP5Type/Base.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Base.py?rev=22309&r1=22308&r2=22309&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Base.py (original)
+++ erp5/trunk/products/ERP5Type/Base.py Mon Jul  7 13:44:24 2008
@@ -1096,7 +1096,22 @@
           econtext = createExpressionContext(self)
           return expression(econtext)
         else:
-          return value
+          if is_list_type:
+            # We must provide the first element of the acquired list
+            if value in null_value:
+              result = None
+            else:
+              if isinstance(value, (list, tuple)):
+                if len(value) is 0:
+                  result = None
+                else:
+                  result = value[0]
+              else:
+                result = value
+          else:
+            # Value is a simple type
+            result = value
+          return result
 
       #Look at acquisition object before call acquisition
       if acquisition_object_id is not None:
@@ -2523,7 +2538,7 @@
   security.declareProtected(Permissions.View, '__call__')
 
   security.declareProtected(Permissions.View, 'list')
-  def list(self,reset=0):
+  def list(self, reset=0):
     """
     Returns the default list even if folder_contents is overridden.
     """




More information about the Erp5-report mailing list