Detail: in_objectlist (my 2 cents) (python)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
@register.filter
def in_objectlist(item, items):
    """
    This filter will check if a item exists in a object list like:
    [<Tag: personal>, <Tag: twitt>]
    """
    try:
        values = [slugify(k) for k in items.keys()]
        if  item in values:
            return True
    except:
        # we should try to detect a specific error here!
        pass
    return False

[raw] - Pasted by: Wu on python on May 26, 2011