Esempio n. 1
0
def drilldown_key( slug, obj_type ):
    label = u''
    try:
        slugs = slug.split('/')
        
        if len(slugs) == 1:
            
            if _search_drilldown_cache.has_object(obj_type, slug):
                label = _search_drilldown_cache.get_object(obj_type, slug)['data']['label']
                label = label.capitalize()
            else:
                label = slug.capitalize()
        else:
            
            if obj_type in ('admin3','admin2'):
                label = _search_drilldown_cache.get_object(obj_type, slugs[0])['data']['label']
            elif obj_type in ('label','slug'):
                label = _search_drilldown_cache.get_object(obj_type, slugs[1])['data']['label']
            else:
                label = slug.capitalize()
    
            label = label.capitalize()
    except:
        label = slug.capitalize()
    
    if _search_drilldown_cache.has_key(slug):
        label += ' ('+_search_drilldown_cache.get_key_data(slug)[obj_type]+')'
    
    return label
Esempio n. 2
0
def drilldown_key_count( slug, obj_type ):
    
    #if slug.startswith(obj_type):
    #    slug = slug[len(obj_type+'-'):]
    
    try:
        if _search_drilldown_cache.has_key(slug) \
            and obj_type in _search_drilldown_cache.get_key_data(slug).keys():
            
            return  _search_drilldown_cache.get_key_data(slug)[obj_type][slug]
        else:
            return _search_drilldown_cache.get_object(obj_type, slug)['count']
    except:
        traceback.print_exc()
        return '?'