コード例 #1
0
def get_category_items_cached():
    """
    Returns all used category items as set.
    """

    # Cache get
    category_items = named_values.get_value(name=CATEGORY_ITEMS)
    if category_items is not None:
        return category_items

    # Fetch category items direct from the Address model
    category_items = get_category_items_direct()

    # Cache set
    named_values.set_value(name=CATEGORY_ITEMS, value=category_items)

    # Finished
    return category_items
コード例 #2
0
def get_category_items_cached():
    """
    Returns all used category items as set.
    """

    # Cache get
    category_items = named_values.get_value(name = CATEGORY_ITEMS)
    if category_items is not None:
        return category_items

    # Fetch category items direct from the Address model
    category_items = get_category_items_direct()

    # Cache set
    named_values.set_value(name = CATEGORY_ITEMS, value = category_items)

    # Finished
    return category_items
コード例 #3
0
def get_tag_items_cached():
    """
    Returns all used tag items as set.
    """

    # Cache get
    tag_items = named_values.get_value(name = TAG_ITEMS)
    if tag_items is not None:
        return tag_items

    # Fetch tag items direct from the Address model
    tag_items = get_tag_items_direct()

    # Cache set
    named_values.set_value(name = TAG_ITEMS, value = tag_items)

    # Finished
    return tag_items
コード例 #4
0
def get_tag_items_cached():
    """
    Returns all used tag items as set.
    """

    # Cache get
    tag_items = named_values.get_value(name=TAG_ITEMS)
    if tag_items is not None:
        return tag_items

    # Fetch tag items direct from the Address model
    tag_items = get_tag_items_direct()

    # Cache set
    named_values.set_value(name=TAG_ITEMS, value=tag_items)

    # Finished
    return tag_items
コード例 #5
0
def get_business_items_cached():
    """
    Returns all used business items as set.
    """

    # Cache get
    business_items = named_values.get_value(name=BUSINESS_ITEMS)
    if business_items is not None:
        return business_items

    # Fetch business items direct from the Address model
    business_items = get_business_items_direct()

    # Cache set
    named_values.set_value(name=BUSINESS_ITEMS, value=business_items)

    # Finished
    return business_items
コード例 #6
0
def add_category_items_to_cache(category_items):
    """
    Add category items to the cache
    """

    if isinstance(category_items, basestring):
        category_items = [category_items]

    # Cache get
    cached_category_items = named_values.get_value(name = CATEGORY_ITEMS)
    if cached_category_items is None:
        cached_category_items = set()

    # Add new category items
    for category_item in category_items:
        cached_category_items.add(category_item)

    # Cache set
    named_values.set_value(name = CATEGORY_ITEMS, value = cached_category_items)
コード例 #7
0
def add_tag_items_to_cache(tag_items):
    """
    Add tag items to the cache
    """

    if isinstance(tag_items, basestring):
        tag_items = [tag_items]

    # Cache get
    cached_tag_items = named_values.get_value(name = TAG_ITEMS)
    if cached_tag_items is None:
        cached_tag_items = set()

    # Add new tag items
    for tag_item in tag_items:
        cached_tag_items.add(tag_item)

    # Cache set
    named_values.set_value(name = TAG_ITEMS, value = cached_tag_items)
コード例 #8
0
def add_category_items_to_cache(category_items):
    """
    Add category items to the cache
    """

    if isinstance(category_items, basestring):
        category_items = [category_items]

    # Cache get
    cached_category_items = named_values.get_value(name=CATEGORY_ITEMS)
    if cached_category_items is None:
        cached_category_items = set()

    # Add new category items
    for category_item in category_items:
        cached_category_items.add(category_item)

    # Cache set
    named_values.set_value(name=CATEGORY_ITEMS, value=cached_category_items)
コード例 #9
0
def add_tag_items_to_cache(tag_items):
    """
    Add tag items to the cache
    """

    if isinstance(tag_items, basestring):
        tag_items = [tag_items]

    # Cache get
    cached_tag_items = named_values.get_value(name=TAG_ITEMS)
    if cached_tag_items is None:
        cached_tag_items = set()

    # Add new tag items
    for tag_item in tag_items:
        cached_tag_items.add(tag_item)

    # Cache set
    named_values.set_value(name=TAG_ITEMS, value=cached_tag_items)
コード例 #10
0
def add_business_items_to_cache(business_items):
    """
    Add business items to the cache
    """

    if isinstance(business_items, basestring):
        business_items = [business_items]

    # Cache get
    cached_business_items = named_values.get_value(name=BUSINESS_ITEMS)
    if cached_business_items is None:
        cached_business_items = set()

    # Add new business items
    for business_item in business_items:
        cached_business_items.add(business_item)

    # Cache set
    named_values.set_value(name=BUSINESS_ITEMS, value=cached_business_items)