Commit cd079de8 authored by Jean-Paul Smets's avatar Jean-Paul Smets

added support for default value in category accessor


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@3802 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f230f61c
...@@ -139,11 +139,15 @@ class DefaultGetter(Method): ...@@ -139,11 +139,15 @@ class DefaultGetter(Method):
self._key = key self._key = key
def __call__(self, instance, *args, **kw): def __call__(self, instance, *args, **kw):
if len(args) > 0:
default = args[0]
else:
default = None
return instance._getDefaultAcquiredCategoryMembership(self._key, return instance._getDefaultAcquiredCategoryMembership(self._key,
spec=kw.get('spec',()), spec=kw.get('spec',()),
filter=kw.get('filter', None), filter=kw.get('filter', None),
portal_type=kw.get('portal_type',()), portal_type=kw.get('portal_type',()),
base=0) base=0, default=default)
psyco.bind(__call__) psyco.bind(__call__)
class ListGetter(Method): class ListGetter(Method):
......
...@@ -1391,13 +1391,13 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): ...@@ -1391,13 +1391,13 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ):
security.declareProtected( Permissions.View, '_getDefaultAcquiredCategoryMembership' ) security.declareProtected( Permissions.View, '_getDefaultAcquiredCategoryMembership' )
def _getDefaultAcquiredCategoryMembership(self, category, def _getDefaultAcquiredCategoryMembership(self, category,
spec=(), filter=None, portal_type=(), base=0): spec=(), filter=None, portal_type=(), base=0, default=None):
membership = self._getAcquiredCategoryMembershipList(category, membership = self._getAcquiredCategoryMembershipList(category,
spec=spec, filter=filter, portal_type=portal_type, base=base) spec=spec, filter=filter, portal_type=portal_type, base=base)
if len(membership) > 0: if len(membership) > 0:
return membership[0] return membership[0]
else: else:
return None return default
security.declareProtected( Permissions.View, 'getDefaultAcquiredCategoryMembership' ) security.declareProtected( Permissions.View, 'getDefaultAcquiredCategoryMembership' )
getDefaultAcquiredCategoryMembership = _getDefaultAcquiredCategoryMembership getDefaultAcquiredCategoryMembership = _getDefaultAcquiredCategoryMembership
......
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