Beispiel #1
0
        pass  # fail silently
pre_delete.connect(order_item_listener, sender=OrderItem)
post_save.connect(order_item_listener, sender=OrderItem)


# Page
def page_saved_listener(sender, instance, **kwargs):
    cache.delete("%s-page-%s" % (settings.CACHE_MIDDLEWARE_KEY_PREFIX, instance.slug))
    cache.delete("%s-pages" % settings.CACHE_MIDDLEWARE_KEY_PREFIX)
post_save.connect(page_saved_listener, sender=Page)


# Product
def product_changed_listener(sender, **kwargs):
    update_product_cache(sender)
product_changed.connect(product_changed_listener)


def product_saved_listener(sender, instance, **kwargs):
    # update_product_cache(instance)
    update_category_cache(instance)
post_save.connect(product_saved_listener, sender=Product)


# Shipping Method
def shipping_method_saved_listener(sender, instance, **kwargs):
    cache.delete("%s-shipping-delivery-time" % settings.CACHE_MIDDLEWARE_KEY_PREFIX)
    cache.delete("%s-shipping-delivery-time-cart" % settings.CACHE_MIDDLEWARE_KEY_PREFIX)
post_save.connect(shipping_method_saved_listener, sender=ShippingMethod)

Beispiel #2
0
# Page
def page_saved_listener(sender, instance, **kwargs):
    cache.delete("%s-page-%s" %
                 (settings.CACHE_MIDDLEWARE_KEY_PREFIX, instance.slug))
    cache.delete("%s-pages" % settings.CACHE_MIDDLEWARE_KEY_PREFIX)


post_save.connect(page_saved_listener, sender=Page)


# Product
def product_changed_listener(sender, **kwargs):
    update_product_cache(sender)


product_changed.connect(product_changed_listener)


def product_saved_listener(sender, instance, **kwargs):
    # update_product_cache(instance)
    update_category_cache(instance)


post_save.connect(product_saved_listener, sender=Product)


# Shipping Method
def shipping_method_saved_listener(sender, instance, **kwargs):
    cache.delete("%s-shipping-delivery-time" %
                 settings.CACHE_MIDDLEWARE_KEY_PREFIX)
    cache.delete("%s-shipping-delivery-time-cart" %