Commit de72f978 authored by Alexandre Boeglin's avatar Alexandre Boeglin

* _getDefaultAcquiredProperty: compare value to null_value instead of None.

  null_value is a tuple of all values that should be considered as null for
  this type, and is defined in ERP5Type/Accessor/TypeDefinition.py

* getCompactTitle, getCompactTranslatedTitle: use hasProperty('reference')
  instead of hasReference, as the latter only exists on classes that use the
  reference property.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19830 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0916977a
...@@ -1079,7 +1079,7 @@ class Base( CopyContainer, ...@@ -1079,7 +1079,7 @@ class Base( CopyContainer,
else: else:
value = None value = None
# If we hold an attribute and mask_value is set, return the attribute # If we hold an attribute and mask_value is set, return the attribute
if mask_value and value is not None: if mask_value and value not in null_value:
# Pop context # Pop context
if is_tales_type: if is_tales_type:
expression = Expression(value) expression = Expression(value)
...@@ -1113,7 +1113,7 @@ class Base( CopyContainer, ...@@ -1113,7 +1113,7 @@ class Base( CopyContainer,
setattr(self, storage_id, value) setattr(self, storage_id, value)
if is_list_type: if is_list_type:
# We must provide the first element of the acquired list # We must provide the first element of the acquired list
if value is None: if value in null_value:
result = None result = None
else: else:
if isinstance(value, (list, tuple)): if isinstance(value, (list, tuple)):
...@@ -1128,7 +1128,7 @@ class Base( CopyContainer, ...@@ -1128,7 +1128,7 @@ class Base( CopyContainer,
result = value result = value
else: else:
result = None result = None
if result is not None: if result not in null_value:
return result return result
else: else:
#LOG("alt_accessor_id",0,str(alt_accessor_id)) #LOG("alt_accessor_id",0,str(alt_accessor_id))
...@@ -1138,7 +1138,7 @@ class Base( CopyContainer, ...@@ -1138,7 +1138,7 @@ class Base( CopyContainer,
method = getattr(self, id, None) method = getattr(self, id, None)
if callable(method): if callable(method):
result = method() result = method()
if result is not None: if result not in null_value:
if is_list_type: if is_list_type:
if isinstance(result, (list, tuple)): if isinstance(result, (list, tuple)):
# We must provide the first element of the alternate result # We must provide the first element of the alternate result
...@@ -2402,7 +2402,7 @@ class Base( CopyContainer, ...@@ -2402,7 +2402,7 @@ class Base( CopyContainer,
if self.hasShortTitle(): if self.hasShortTitle():
r = self.getShortTitle() r = self.getShortTitle()
if r: return r if r: return r
if self.hasReference(): if self.getProperty('reference'):
r = self.getReference() r = self.getReference()
if r: return r if r: return r
r = self._baseGetTitle() # No need to test existence since all Base instances have this method r = self._baseGetTitle() # No need to test existence since all Base instances have this method
...@@ -2436,7 +2436,7 @@ class Base( CopyContainer, ...@@ -2436,7 +2436,7 @@ class Base( CopyContainer,
if r: return r if r: return r
r = self.getShortTitle() r = self.getShortTitle()
if r: return r if r: return r
if self.hasReference(): if self.getProperty('reference'):
r = self.getReference() r = self.getReference()
if r: return r if r: return r
r = self._baseGetTranslatedTitle() # No need to test existence since all Base instances have this method r = self._baseGetTranslatedTitle() # No need to test existence since all Base instances have this method
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment