Exemple #1
0
def getParentCategory(object, portal, **kwargs):
    try:
        if ICategory.providedBy(object):
            parent_category = object.getParentCategory()
            if parent_category is not None:
                return parent_category.UID()
            else: 
                return None
        
    except (ComponentLookupError, TypeError, ValueError):
        raise AttributeError
Exemple #2
0
def amount_of_categories(object, portal, **kwargs):
    try:
        # This has to be done without the help of the catalog. Otherwise it
        # counts before all to counted objects are in the catalog. That is at
        # least the case for Advanced/Update Catalog.
        
        counter = 0
        if ICategory.providedBy(object):
            counter = len(object.objectValues("Category"))

        return counter
        
    except (ComponentLookupError, TypeError, ValueError):
        raise AttributeError