Beispiel #1
0

# Category
def category_deleted_listener(sender, instance, **kwargs):
    update_category_cache(instance)
pre_delete.connect(category_deleted_listener, sender=Category)


def category_saved_listener(sender, instance, **kwargs):
    update_category_cache(instance)
pre_save.connect(category_saved_listener, sender=Category)


def category_changed_listener(sender, **kwargs):
    update_category_cache(sender)
category_changed.connect(category_changed_listener)


def product_categories_changed_listener(sender, **kwargs):
    instance = kwargs['instance']
    reverse = kwargs['reverse']
    pk_set = kwargs['pk_set']

    if reverse:
        product = instance
        cache_key = "%s-product-categories-%s-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, product.id, True)
        cache.delete(cache_key)
        cache_key = "%s-product-categories-%s-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, product.id, False)
        cache.delete(cache_key)
    else:
        if pk_set:
Beispiel #2
0
pre_delete.connect(category_deleted_listener, sender=Category)


def category_saved_listener(sender, instance, **kwargs):
    update_category_cache(instance)


pre_save.connect(category_saved_listener, sender=Category)


def category_changed_listener(sender, **kwargs):
    update_category_cache(sender)


category_changed.connect(category_changed_listener)


def product_categories_changed_listener(sender, **kwargs):
    instance = kwargs['instance']
    reverse = kwargs['reverse']
    pk_set = kwargs['pk_set']

    if reverse:
        product = instance
        cache_key = "%s-product-categories-%s-%s" % (
            settings.CACHE_MIDDLEWARE_KEY_PREFIX, product.id, True)
        cache.delete(cache_key)
        cache_key = "%s-product-categories-%s-%s" % (
            settings.CACHE_MIDDLEWARE_KEY_PREFIX, product.id, False)
        cache.delete(cache_key)