def getCategoryMappingChildValueList(category_mapping, sort_on=None, sort_order=None, is_self_excluded=1,local_sort_method=None, local_sort_id=None, **kw): if is_self_excluded: value_list = [] else: value_list = [category_mapping] allowed_type_list = ["Integration Base Category Mapping","Integration Category Mapping"] child_value_list = category_mapping.objectValues(portal_type=allowed_type_list) if local_sort_id: if isinstance(local_sort_id, (tuple, list)): def sort_method(a, b): for sort_id in local_sort_id: diff = cmp(a.getProperty(sort_id, 0), b.getProperty(sort_id, 0)) if diff != 0: return diff return 0 local_sort_method = sort_method else: local_sort_method = lambda a, b: cmp(a.getProperty(local_sort_id, 0), b.getProperty(local_sort_id, 0)) if local_sort_method: # sort objects at the current level child_value_list = list(child_value_list) child_value_list.sort(local_sort_method) # get recursive child value list for c in child_value_list: value_list.extend(getCategoryMappingChildValueList(c, is_self_excluded=0, local_sort_id=local_sort_id, local_sort_method=local_sort_method)) return sortValueList(value_list, sort_on, sort_order, **kw)
def objectValues(self, spec=None, meta_type=None, portal_type=None, sort_on=None, sort_order=None, checked_permission=None, **kw): assert spec is meta_type is checked_permission is None, "not useful yet" object_list = getattr(aq_base(self), '_predicate_list', None) if object_list is None: container_list = tuple(filter(len, self._effective_model_list)) object_list = _findPredicateList(container_list, self._portal_type_list) self._predicate_list = object_list if portal_type is not None: if isinstance(portal_type, str): portal_type = (portal_type,) object_list = filter(lambda x: x.getPortalType() in portal_type, object_list) return sortValueList(object_list, sort_on, sort_order, **kw)
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Utils import sortValueList result = [newTempBase(context, '_', uid=path) for path in context.getVcsTool().getConflictedFileList()] return sortValueList(result, **kw)
def getCategoryChildValueList(self, is_self_excluded=1, recursive=1, include_if_child=1, sort_on=None, sort_order=None, local_sort_method=None, local_sort_id=None, checked_permission=None, **kw): """ List the child objects of this category and all its subcategories. recursive - if set to 1, list recursively include_if_child - if set to 1, then a category is listed even if has childs. if set to 0, then don't list if child. for example: region/europe region/europe/france region/europe/germany ... becomes: region/europe/france region/europe/germany ... sort_on, sort_order - sort categories in 'sort_order' by comparing the 'sort_on' attribute. The default is to do a preorder tree traversal on all subobjects. local_sort_method - When using the default preorder traversal, use this function to sort objects of the same depth. local_sort_id - When using the default preorder traversal, sort objects of the same depth by comparing their 'local_sort_id' property. local_sort_id can be a list, in this case properties are compared in the same order than this list. Renderer parameters are also supported here. """ if is_self_excluded: value_list = [] else: value_list = [self] child_value_list = self.objectValues(self.allowed_types) if local_sort_id: if isinstance(local_sort_id, (tuple, list)): def sort_method(a, b): for sort_id in local_sort_id: diff = cmp(a.getProperty(sort_id, 0), b.getProperty(sort_id, 0)) if diff != 0: return diff return 0 local_sort_method = sort_method else: local_sort_method = lambda a, b: cmp( a.getProperty(local_sort_id, 0), b.getProperty(local_sort_id, 0)) if local_sort_method: # sort objects at the current level child_value_list = list(child_value_list) child_value_list.sort(local_sort_method) if recursive: for c in child_value_list: value_list.extend( c.getCategoryChildValueList( recursive=1, is_self_excluded=0, include_if_child=include_if_child, local_sort_id=local_sort_id, local_sort_method=local_sort_method)) else: for c in child_value_list: if include_if_child: value_list.append(c) else: if len(c.objectIds(self.allowed_types)) == 0: value_list.append(c) if checked_permission is not None: checkPermission = self.portal_membership.checkPermission def permissionFilter(obj): return checkPermission(checked_permission, obj) value_list = filter(permissionFilter, value_list) return sortValueList(value_list, sort_on, sort_order, **kw)
def getCategoryChildValueList(self, recursive=1, include_if_child=1, is_self_excluded=1, sort_on=None, sort_order=None, local_sort_method=None, local_sort_id=None, checked_permission=None, **kw): """ List the child objects of this category and all its subcategories. recursive - if set to 1, list recursively include_if_child - if set to 0, categories having child categories are not included. DEPRECATED, use filter_node=1 if you don't want to display categories having childs. is_self_excluded - if set to 1, exclude this category from the list sort_on, sort_order - the same semantics as ZSQLCatalog sort_on specifies properties used for sorting sort_order specifies how categories are sorted. The default is to do a preorder tree traversal on all sub-objects. WARNING: using these parameters can slow down significantly, because this is written in Python local_sort_method - When using the default preorder traversal, use this function to sort objects of the same depth. local_sort_id - When using the default preorder traversal, sort objects of the same depth by comparing their 'local_sort_id' property. local_sort_id can be a list, in this case properties are compared in the same order than this list. Renderer parameters are also supported here. """ if is_self_excluded or (not (include_if_child) and len(self.objectIds(self.allowed_types)) > 0): value_list = [] else: value_list = [self] child_value_list = self.objectValues(self.allowed_types) if local_sort_id: if isinstance(local_sort_id, (tuple, list)): def sort_method(a, b): for sort_id in local_sort_id: diff = cmp(a.getProperty(sort_id, 0), b.getProperty(sort_id, 0)) if diff != 0: return diff return 0 local_sort_method = sort_method else: local_sort_method = lambda a, b: cmp( a.getProperty(local_sort_id, 0), b.getProperty(local_sort_id, 0)) if local_sort_method: # sort objects at the current level child_value_list = list(child_value_list) child_value_list.sort(local_sort_method) if recursive: for c in child_value_list: # Do not pass sort_on / sort_order parameters intentionally, because # sorting needs to be done only at the end of recursive calls. value_list.extend( c.getCategoryChildValueList( recursive=1, is_self_excluded=0, include_if_child=include_if_child, local_sort_method=local_sort_method, local_sort_id=local_sort_id)) else: for c in child_value_list: value_list.append(c) if checked_permission is not None: checkPermission = self.portal_membership.checkPermission def permissionFilter(obj): return checkPermission(checked_permission, obj) value_list = filter(permissionFilter, value_list) return sortValueList(value_list, sort_on, sort_order, **kw)
def getCategoryChildValueList(self, is_self_excluded=1, recursive=1, include_if_child=1, sort_on=None, sort_order=None, local_sort_method=None, local_sort_id=None, checked_permission=None, **kw): """ List the child objects of this category and all its subcategories. recursive - if set to 1, list recursively include_if_child - if set to 1, then a category is listed even if has childs. if set to 0, then don't list if child. for example: region/europe region/europe/france region/europe/germany ... becomes: region/europe/france region/europe/germany ... sort_on, sort_order - sort categories in 'sort_order' by comparing the 'sort_on' attribute. The default is to do a preorder tree traversal on all subobjects. local_sort_method - When using the default preorder traversal, use this function to sort objects of the same depth. local_sort_id - When using the default preorder traversal, sort objects of the same depth by comparing their 'local_sort_id' property. local_sort_id can be a list, in this case properties are compared in the same order than this list. Renderer parameters are also supported here. """ if is_self_excluded: value_list = [] else: value_list = [self] child_value_list = self.objectValues(self.allowed_types) if local_sort_id: if isinstance(local_sort_id, (tuple, list)): def sort_method(a, b): for sort_id in local_sort_id: diff = cmp(a.getProperty(sort_id, 0), b.getProperty(sort_id, 0)) if diff != 0: return diff return 0 local_sort_method = sort_method else: local_sort_method = lambda a, b: cmp(a.getProperty(local_sort_id, 0), b.getProperty(local_sort_id, 0)) if local_sort_method: # sort objects at the current level child_value_list = list(child_value_list) child_value_list.sort(local_sort_method) if recursive: for c in child_value_list: value_list.extend(c.getCategoryChildValueList(recursive=1, is_self_excluded=0, include_if_child=include_if_child, local_sort_id=local_sort_id, local_sort_method=local_sort_method)) else: for c in child_value_list: if include_if_child: value_list.append(c) else: if len(c.objectIds(self.allowed_types))==0: value_list.append(c) if checked_permission is not None: checkPermission = self.portal_membership.checkPermission def permissionFilter(obj): return checkPermission(checked_permission, obj) value_list = filter(permissionFilter, value_list) return sortValueList(value_list, sort_on, sort_order, **kw)
def getCategoryChildValueList(self, recursive=1, include_if_child=1, is_self_excluded=1, sort_on=None, sort_order=None, local_sort_method=None, local_sort_id=None, checked_permission=None, **kw): """ List the child objects of this category and all its subcategories. recursive - if set to 1, list recursively include_if_child - if set to 0, categories having child categories are not included. DEPRECATED, use filter_node=1 if you don't want to display categories having childs. is_self_excluded - if set to 1, exclude this category from the list sort_on, sort_order - the same semantics as ZSQLCatalog sort_on specifies properties used for sorting sort_order specifies how categories are sorted. The default is to do a preorder tree traversal on all sub-objects. WARNING: using these parameters can slow down significantly, because this is written in Python local_sort_method - When using the default preorder traversal, use this function to sort objects of the same depth. local_sort_id - When using the default preorder traversal, sort objects of the same depth by comparing their 'local_sort_id' property. local_sort_id can be a list, in this case properties are compared in the same order than this list. Renderer parameters are also supported here. """ if is_self_excluded or ( not(include_if_child) and len(self.objectIds(self.allowed_types)) > 0): value_list = [] else: value_list = [self] child_value_list = self.objectValues(self.allowed_types) if local_sort_id: if isinstance(local_sort_id, (tuple, list)): def sort_method(a, b): for sort_id in local_sort_id: diff = cmp(a.getProperty(sort_id, 0), b.getProperty(sort_id, 0)) if diff != 0: return diff return 0 local_sort_method = sort_method else: local_sort_method = lambda a, b: cmp(a.getProperty(local_sort_id, 0), b.getProperty(local_sort_id, 0)) if local_sort_method: # sort objects at the current level child_value_list = list(child_value_list) child_value_list.sort(local_sort_method) if recursive: for c in child_value_list: # Do not pass sort_on / sort_order parameters intentionally, because # sorting needs to be done only at the end of recursive calls. value_list.extend(c.getCategoryChildValueList(recursive=1, is_self_excluded=0, include_if_child=include_if_child, local_sort_method=local_sort_method, local_sort_id=local_sort_id)) else: for c in child_value_list: value_list.append(c) if checked_permission is not None: checkPermission = self.portal_membership.checkPermission def permissionFilter(obj): return checkPermission(checked_permission, obj) value_list = filter(permissionFilter, value_list) return sortValueList(value_list, sort_on, sort_order, **kw)