Commit 538b8573 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Fixed testPreferences test. General review of tales expressions and definition...

Fixed testPreferences test. General review of tales expressions and definition of results through tests is required.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17642 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f400b6ca
...@@ -34,6 +34,7 @@ from TypeDefinition import asList, identity ...@@ -34,6 +34,7 @@ from TypeDefinition import asList, identity
import Base import Base
from Products.ERP5Type.PsycoWrapper import psyco from Products.ERP5Type.PsycoWrapper import psyco
from Acquisition import aq_base from Acquisition import aq_base
from types import ListType, TupleType
from zLOG import LOG from zLOG import LOG
...@@ -234,8 +235,13 @@ class DefaultGetter(Method): ...@@ -234,8 +235,13 @@ class DefaultGetter(Method):
list_value = evaluateTales(instance=instance, value=list_value) list_value = evaluateTales(instance=instance, value=list_value)
else: else:
return list_value return list_value
if type(list_value) in (ListType, TupleType):
if len(list_value) > 0: if len(list_value) > 0:
return list_value[0] return list_value[0]
else:
return None
# This should not happen though
return list_value
if default and len(default): if default and len(default):
return default[0] return default[0]
return None return None
...@@ -285,10 +291,14 @@ class ListGetter(Method): ...@@ -285,10 +291,14 @@ class ListGetter(Method):
list_value = evaluateTales(instance=instance, value=list_value) list_value = evaluateTales(instance=instance, value=list_value)
else: else:
return list_value return list_value
return list(list_value) if type(list_value) is TupleType:
return list(list_value) # Make sure we return a list rather than a tuple
return list_value
if default is None: if default is None:
return None # nothing was defined as default so None is the right value return None # nothing was defined as default so None is the appropriate value
if type(default) is TupleType:
return list(default) # Make sure we return a list rather than a tuple return list(default) # Make sure we return a list rather than a tuple
return default
psyco.bind(__call__) psyco.bind(__call__)
......
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