From bc634b05d7e9a88eced2116578af786ce9a720db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Tue, 21 Jun 2005 13:41:51 +0000 Subject: [PATCH] rename keyword strict to strict_membership in category membership generated methods. (Bug #42) git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3293 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/Accessor/RelatedValue.py | 53 +++++++++++++++-------- product/ERP5Type/Base.py | 23 +++++++--- 2 files changed, 52 insertions(+), 24 deletions(-) diff --git a/product/ERP5Type/Accessor/RelatedValue.py b/product/ERP5Type/Accessor/RelatedValue.py index ec194adcb8..c1f34fb996 100755 --- a/product/ERP5Type/Accessor/RelatedValue.py +++ b/product/ERP5Type/Accessor/RelatedValue.py @@ -43,6 +43,8 @@ class DefaultGetter(Method): func_defaults = () def __init__(self, id, key, warning=0): + """ 'warning' argument means that this category is deprecated in the + property sheet, so the generated method will also be deprecated """ self._id = id self.__name__ = id self._key = key @@ -52,9 +54,11 @@ class DefaultGetter(Method): if self._warning: LOG("ERP5Type Deprecated Getter Id:",0, self._id) return instance._getDefaultRelatedValue(self._key, - spec=kw.get('spec',()), - filter=kw.get('filter', None), - portal_type=kw.get('portal_type',())) + spec=kw.get('spec',()), + filter=kw.get('filter', None), + portal_type=kw.get('portal_type',()), + strict_membership=kw.get('strict_membership', + kw.get('strict', None))) # 'strict' is deprecated psyco.bind(__call__) @@ -74,6 +78,8 @@ class ListGetter(Method): func_defaults = () def __init__(self, id, key, warning=0): + """ 'warning' argument means that this category is deprecated in the + property sheet, so the generated method will also be deprecated """ self._id = id self.__name__ = id self._key = key @@ -83,9 +89,11 @@ class ListGetter(Method): if self._warning: LOG("ERP5Type Deprecated Getter Id:",0, self._id) return instance._getRelatedValueList(self._key, - spec=kw.get('spec',()), - filter=kw.get('filter', None), - portal_type=kw.get('portal_type',())) + spec=kw.get('spec',()), + filter=kw.get('filter', None), + portal_type=kw.get('portal_type',()), + strict_membership=kw.get('strict_membership', + kw.get('strict', None))) # 'strict' is deprecated psyco.bind(__call__) @@ -116,7 +124,10 @@ class DefaultIdGetter(Method): return instance._getDefaultRelatedProperty(self._key, 'id', spec=kw.get('spec',()), filter=kw.get('filter', None), - portal_type=kw.get('portal_type',())) + portal_type=kw.get('portal_type',()), + strict_membership=kw.get('strict_membership', + kw.get('strict', None))) # 'strict' is deprecated + psyco.bind(__call__) @@ -145,9 +156,11 @@ class IdListGetter(Method): if self._warning: LOG("ERP5Type Deprecated Getter Id:",0, self._id) return instance._getRelatedPropertyList(self._key, 'id', - spec=kw.get('spec',()), - filter=kw.get('filter', None), - portal_type=kw.get('portal_type',())) + spec=kw.get('spec',()), + filter=kw.get('filter', None), + portal_type=kw.get('portal_type',()), + strict_membership=kw.get('strict_membership', + kw.get('strict', None))) # 'strict' is deprecated psyco.bind(__call__) @@ -178,7 +191,10 @@ class DefaultTitleGetter(Method): return instance._getDefaultRelatedProperty(self._key, 'title', spec=kw.get('spec',()), filter=kw.get('filter', None), - portal_type=kw.get('portal_type',())) + portal_type=kw.get('portal_type',(), + strict_membership=kw.get('strict_membership', + kw.get('strict', None))) # 'strict' is deprecated + psyco.bind(__call__) @@ -209,8 +225,9 @@ class TitleListGetter(Method): return instance._getRelatedPropertyList(self._key, 'title', spec=kw.get('spec',()), filter=kw.get('filter', None), - portal_type=kw.get('portal_type',())) - + portal_type=kw.get('portal_type',()), + strict_membership=kw.get('strict_membership', + kw.get('strict', None))) # 'strict' is deprecated psyco.bind(__call__) TitleSetGetter = TitleListGetter # XXX Error @@ -240,8 +257,9 @@ class DefaultPropertyGetter(Method): return instance._getDefaultRelatedProperty(self._key, key, spec=kw.get('spec',()), filter=kw.get('filter', None), - portal_type=kw.get('portal_type',())) - + portal_type=kw.get('portal_type',()), + strict_membership=kw.get('strict_membership', + kw.get('strict', None))) # 'strict' is deprecated psyco.bind(__call__) PropertyGetter = DefaultPropertyGetter @@ -271,8 +289,9 @@ class PropertyListGetter(Method): return instance._getRelatedPropertyList(self._key, key, spec=kw.get('spec',()), filter=kw.get('filter', None), - portal_type=kw.get('portal_type',())) - + portal_type=kw.get('portal_type',()), + strict_membership=kw.get('strict_membership', + kw.get('strict', None))) # 'strict' is deprecated psyco.bind(__call__) PropertySetGetter = PropertyListGetter # Error XXX diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py index a21d68f419..c50b3f7c99 100755 --- a/product/ERP5Type/Base.py +++ b/product/ERP5Type/Base.py @@ -1192,21 +1192,30 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): getAcquiredValueList = _getAcquiredValueList security.declareProtected( Permissions.View, '_getDefaultRelatedValue' ) - def _getDefaultRelatedValue(self, id, spec=(), filter=None, portal_type=(), strict=0): - value_list =self._getRelatedValueList(id, spec=spec, filter=filter, portal_type=portal_type, strict=strict) + def _getDefaultRelatedValue(self, id, spec=(), filter=None, portal_type=(), + strict_membership=0, strict="deprecated"): + # backward compatibility to keep strict keyword working + if strict != "deprecated" : strict_membership = strict + value_list =self._getRelatedValueList(id, spec=spec, filter=filter, + portal_type=portal_type, + strict_membership=strict_membership) try: return value_list[0] - except: + except IndexError: return None security.declareProtected( Permissions.View, 'getDefaultRelatedValue' ) getDefaultRelatedValue = _getDefaultRelatedValue security.declareProtected( Permissions.View, '_getRelatedValueList' ) - def _getRelatedValueList(self, id, spec=(), filter=None, portal_type=(), strict=0): - return self._getCategoryTool().getRelatedValueList(self, id, - spec=spec, filter=filter, portal_type=portal_type, strict=strict) - + def _getRelatedValueList(self, id, spec=(), filter=None, portal_type=(), + strict_membership=0, strict="deprecated"): + # backward compatibility to keep strict keyword working + if strict != "deprecated" : strict_membership = strict + return self._getCategoryTool().getRelatedValueList(self, id, + spec=spec, filter=filter, portal_type=portal_type, + strict_membership=strict_membership) + security.declareProtected( Permissions.View, 'getRelatedValueList' ) getRelatedValueList = _getRelatedValueList -- 2.30.9