Commit 1cdc2f52 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Make CMFCategory test pass again (Value accessor implementation now made...

Make CMFCategory test pass again (Value accessor implementation now made consistent for both categories and documents)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10028 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 163582bf
...@@ -1291,27 +1291,32 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property ...@@ -1291,27 +1291,32 @@ class Base( CopyContainer, PortalContent, ActiveObject, Historical, ERP5Property
# categories # categories
security.declareProtected( Permissions.ModifyPortalContent, '_setValue' ) security.declareProtected( Permissions.ModifyPortalContent, '_setValue' )
def _setValue(self, id, target, spec=(), filter=None, portal_type=(), keep_default=1): def _setValue(self, id, target, spec=(), filter=None, portal_type=(), keep_default=1):
start_string = "%s/" % id
start_string_len = len(start_string)
if target is None : if target is None :
path = target path = target
elif isinstance(target, str): elif isinstance(target, str):
# We have been provided a string # We have been provided a string
path = target path = target
if path.startswith(start_string): path = path[start_string_len:] # Prevent duplicating base category
elif isinstance(target, (tuple, list)): elif isinstance(target, (tuple, list)):
# We have been provided a list or tuple # We have been provided a list or tuple
path_list = [] path_list = []
for target_item in target: for target_item in target:
if isinstance(target_item, str): if isinstance(target_item, str):
path_list += [target_item] path = target_item
else: else:
path = target_item.getRelativeUrl() path = target_item.getRelativeUrl()
if path.startswith(start_string): path = path[start_string_len:] # Prevent duplicating base category
path_list += [path] path_list += [path]
path = path_list path = path_list
else: else:
# We have been provided an object # We have been provided an object
# Find the object # Find the object
path = target.getRelativeUrl() path = target.getRelativeUrl()
if path.startswith(start_string): path = path[start_string_len:] # Prevent duplicating base category
self._setCategoryMembership(id, path, spec=spec, filter=filter, portal_type=portal_type, self._setCategoryMembership(id, path, spec=spec, filter=filter, portal_type=portal_type,
base=1, keep_default=keep_default) base=0, keep_default=keep_default)
security.declareProtected( Permissions.ModifyPortalContent, '_setValueList' ) security.declareProtected( Permissions.ModifyPortalContent, '_setValueList' )
_setValueList = _setValue _setValueList = _setValue
......
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