diff --git a/product/ERP5Type/Accessor/RelatedValue.py b/product/ERP5Type/Accessor/RelatedValue.py index c55fadf273beb41d0f9f99916599a17767b1719c..9e8026e13de54068edf4363fa29330c5a9aec4a7 100644 --- a/product/ERP5Type/Accessor/RelatedValue.py +++ b/product/ERP5Type/Accessor/RelatedValue.py @@ -111,163 +111,6 @@ class SetGetter(ListGetter): result_set = dict([(x, 0) for x in result_list]).keys() return result_set -class DefaultIdGetter(BaseGetter): - """ - Gets a default reference object - """ - _need__name__=1 - - # Generic Definition of Method Object - # This is required to call the method form the Web - func_code = func_code() - func_code.co_varnames = ('self', ) - func_code.co_argcount = 1 - func_defaults = () - - def __init__(self, id, key, warning=0): - self._id = id - self.__name__ = id - self._key = key - self._warning = warning - - def __call__(self, instance, *args, **kw): - if self._warning: - LOG("ERP5Type", WARNING, "Deprecated Getter Id: %s" % self._id) - return instance._getDefaultRelatedProperty( - self._key, 'id', - spec=kw.get('spec',()), - filter=kw.get('filter', None), - portal_type=kw.get('portal_type',()), - strict_membership=kw.get('strict_membership', - # 'strict' is deprecated - kw.get('strict', None)), - checked_permission=kw.get('checked_permission', None)) - - psyco.bind(__call__) - -IdGetter = DefaultIdGetter - -class IdListGetter(BaseGetter): - """ - Gets a list of reference objects - """ - _need__name__=1 - - # Generic Definition of Method Object - # This is required to call the method form the Web - func_code = func_code() - func_code.co_varnames = ('self', ) - func_code.co_argcount = 1 - func_defaults = () - - def __init__(self, id, key, warning=0): - self._id = id - self.__name__ = id - self._key = key - self._warning = warning - - def __call__(self, instance, *args, **kw): - if self._warning: - LOG("ERP5Type", WARNING, "Deprecated Getter Id: %s" % self._id) - return instance._getRelatedPropertyList( - self._key, 'id', - spec=kw.get('spec',()), - filter=kw.get('filter', None), - portal_type=kw.get('portal_type',()), - strict_membership=kw.get('strict_membership', - # 'strict' is deprecated - kw.get('strict', None)), - checked_permission=kw.get('checked_permission', None)) - - psyco.bind(__call__) - -class IdSetGetter(IdListGetter): - """ - Gets a category value set - """ - def __call__(self, instance, *args, **kw): - result_list = IdListGetter.__call__(self, instance, *args, **kw) - result_set = dict([(x, 0) for x in result_list]).keys() - return result_set - -class DefaultTitleGetter(BaseGetter): - """ - Gets a default reference object - """ - _need__name__=1 - - # Generic Definition of Method Object - # This is required to call the method form the Web - func_code = func_code() - func_code.co_varnames = ('self', ) - func_code.co_argcount = 1 - func_defaults = () - - def __init__(self, id, key, warning=0): - self._id = id - self.__name__ = id - self._key = key - self._warning = warning - - def __call__(self, instance, *args, **kw): - if self._warning: - LOG("ERP5Type", WARNING, "Deprecated Getter Id: %s" % self._id) - return instance._getDefaultRelatedProperty( - self._key, 'title', - spec=kw.get('spec',()), - filter=kw.get('filter', None), - portal_type=kw.get('portal_type',()), - strict_membership=kw.get('strict_membership', - # 'strict' is deprecated - kw.get('strict', None)), - checked_permission=kw.get('checked_permission', None)) - - psyco.bind(__call__) - -TitleGetter = DefaultTitleGetter - -class TitleListGetter(BaseGetter): - """ - Gets a list of reference objects - """ - _need__name__=1 - - # Generic Definition of Method Object - # This is required to call the method form the Web - func_code = func_code() - func_code.co_varnames = ('self', ) - func_code.co_argcount = 1 - func_defaults = () - - def __init__(self, id, key, warning=0): - self._id = id - self.__name__ = id - self._key = key - self._warning = warning - - def __call__(self, instance, *args, **kw): - if self._warning: - LOG("ERP5Type", WARNING, "Deprecated Getter Id: %s" % self._id) - return instance._getRelatedPropertyList( - self._key, 'title', - spec=kw.get('spec',()), - filter=kw.get('filter', None), - portal_type=kw.get('portal_type',()), - strict_membership=kw.get('strict_membership', - # 'strict' is deprecated - kw.get('strict', None)), - checked_permission=kw.get('checked_permission', None)) - - psyco.bind(__call__) - -class TitleSetGetter(TitleListGetter): - """ - Gets a category value set - """ - def __call__(self, instance, *args, **kw): - result_list = TitleListGetter.__call__(self, instance, *args, **kw) - result_set = dict([(x, 0) for x in result_list]).keys() - return result_set class DefaultPropertyGetter(BaseGetter): """ @@ -345,3 +188,31 @@ class PropertySetGetter(PropertyListGetter): result_list = PropertyListGetter.__call__(self, instance, *args, **kw) result_set = dict([(x, 0) for x in result_list]).keys() return result_set + + +class DefaultIdGetter(PropertyGetter): + def __call__(self, instance, *args, **kw): + return PropertyGetter.__call__(self, instance, 'id', *args, **kw) +IdGetter = DefaultIdGetter + +class IdListGetter(PropertyListGetter): + def __call__(self, instance, *args, **kw): + return PropertyListGetter.__call__(self, instance, 'id', *args, **kw) + +class IdSetGetter(PropertySetGetter): + def __call__(self, instance, *args, **kw): + return PropertySetGetter.__call__(self, instance, 'id', *args, **kw) + + +class DefaultTitleGetter(PropertyGetter): + def __call__(self, instance, *args, **kw): + return PropertyGetter.__call__(self, instance, 'title', *args, **kw) +TitleGetter = DefaultTitleGetter + +class TitleListGetter(PropertyListGetter): + def __call__(self, instance, *args, **kw): + return PropertyListGetter.__call__(self, instance, 'title', *args, **kw) + +class TitleSetGetter(PropertySetGetter): + def __call__(self, instance, *args, **kw): + return PropertySetGetter.__call__(self, instance, 'title', *args, **kw) diff --git a/product/ERP5Type/tests/testERP5Type.py b/product/ERP5Type/tests/testERP5Type.py index 013a8f222f17bfe359c6e58de9fd95e352d59c39..12dc9ae8014543e1f62422258b624821777abdf9 100644 --- a/product/ERP5Type/tests/testERP5Type.py +++ b/product/ERP5Type/tests/testERP5Type.py @@ -398,10 +398,15 @@ class TestERP5Type(PropertySheetTestCase, LogInterceptor): portal_type = "Person"), [person_object] ) self.assertEquals( category_object.getRegionRelatedTitleList( portal_type = "Person"), [person_title] ) + self.assertEquals( category_object.getRegionRelatedTitleSet( + portal_type = "Person"), [person_title] ) self.assertEquals( category_object.getRegionRelatedList( portal_type = "Person"), [person_relative_url] ) self.assertEquals( category_object.getRegionRelatedIdList( portal_type = "Person"), [person_id] ) + self.assertEquals( category_object.getRegionRelatedIdSet( + portal_type = "Person"), [person_id] ) + def checkRelationUnset(self): self.commit() person_object.reindexObject()