authorizer_appid = ComponentAuthedAppid.objects.get(user_id=user_profile.user_id) try: delete_component_auth_cache(authorizer_appid.authorizer_appid) #get_accounts(openid, webapp_id) except: pass except: pass else: instances = list(instance) for integral_strategy_settings in instances: try: user_profile = UserProfile.objects.get(webapp_id=integral_strategy_settings.webapp_id) authorizer_appid = ComponentAuthedAppid.objects.get(user_id=user_profile.user_id) try: delete_component_auth_cache(authorizer_appid.authorizer_appid) except: pass except: pass return post_update_signal.connect(update_component_cache_for_auther_appid, sender=ComponentAuthedAppid, dispatch_uid = "ComponentInfo.update") #signals.post_save.connect(update_component_cache_for_integral_settings, sender=member_models.IntegralStrategySttings, dispatch_uid = "member_models.IntegralStrategySttings.save") post_update_signal.connect(update_component_cache_for_integral_settings, sender=member_models.IntegralStrategySttings, dispatch_uid = "member_models.IntegralStrategySttings.update") #signals.post_save.connect(update_webapp_product_cache, sender=mall_models.ProductCategory, dispatch_uid = "product_category.save") #signals.post_save.connect(update_webapp_product_cache, sender=mall_models.CategoryHasProduct, dispatch_uid = "category_has_product.save")
get_webapp_products_from_db(webapp_owner_user_profile, is_access_weizoom_mall)) local_cache[key] = data return mall_models.ProductCategory.from_list(data['categories']) def update_webapp_product_cache(**kwargs): if hasattr(cache, 'request') and cache.request.user_profile: webapp_owner_id = cache.request.user_profile.user_id key = 'webapp_products_categories_{wo:%s}' % webapp_owner_id cache_util.delete_cache(key) post_update_signal.connect(update_webapp_product_cache, sender=mall_models.Product, dispatch_uid="product.update") signals.post_save.connect(update_webapp_product_cache, sender=mall_models.Product, dispatch_uid="product.save") signals.post_save.connect(update_webapp_product_cache, sender=mall_models.ProductCategory, dispatch_uid="product_category.save") signals.post_save.connect(update_webapp_product_cache, sender=mall_models.CategoryHasProduct, dispatch_uid="category_has_product.save") post_delete_signal.connect(update_webapp_product_cache, sender=mall_models.ProductCategory, dispatch_uid="mall_product_category.delete") post_delete_signal.connect(update_webapp_product_cache, sender=mall_models.CategoryHasProduct,
webapp_user_id = order.webapp_user_id if webapp_user_id: try: key = get_order_stats_cache_key(webapp_user_id) cache_util.delete_cache(key) except: pass return """ 注册signal: 当Order出现save操作时,触发update_webapp_order_cache() """ post_update_signal.connect(update_webapp_order_cache, sender=Order, dispatch_uid="order.update") signals.post_save.connect(update_webapp_order_cache, sender=Order, dispatch_uid="order.save") def update_webapp_order_by_review_picture_cache(instance, **kwargs): if hasattr(cache, 'request'): webapp_user_id = cache.request.webapp_user.id try: key = get_order_stats_cache_key(webapp_user_id) cache_util.delete_cache(key) except: pass
from django.dispatch.dispatcher import receiver from django.db.models import signals from weapp.hack_django import post_update_signal def update_auto_qa_message_cache(**kwargs): if hasattr(cache, 'request'): if hasattr(cache.request.user_profile, 'webapp_id'): webapp_id = cache.request.user_profile.webapp_id key = 'auto_qa_message_webapp_id_%s_*' % (webapp_id) cache_util.delete_pattern(key) post_update_signal.connect(update_auto_qa_message_cache, sender=News, dispatch_uid="material_news.update") signals.post_save.connect(update_auto_qa_message_cache, sender=News, dispatch_uid="material_news.save") post_update_signal.connect(update_auto_qa_message_cache, sender=Rule, dispatch_uid="qa_rule.update") signals.post_save.connect(update_auto_qa_message_cache, sender=Rule, dispatch_uid="qa_rule.save") signals.post_delete.connect(update_auto_qa_message_cache, sender=News, dispatch_uid="material_news.delete")
from webapp import models as webapp_models def delete_webapp_page_cache(**kwargs): if hasattr(cache, 'request') and cache.request.user_profile: webapp_owner_id = cache.request.user_profile.user_id for project in webapp_models.Project.objects.filter( owner_id=webapp_owner_id, type='wepage'): key = 'termite_webapp_page_%s_%s' % (webapp_owner_id, project.id) cache_util.delete_cache(key) purge_webapp_page_from_varnish_cache.delay(webapp_owner_id, project.id) post_update_signal.connect(delete_webapp_page_cache, sender=mall_models.Product, dispatch_uid="termite_product.update") signals.post_save.connect(delete_webapp_page_cache, sender=mall_models.Product, dispatch_uid="termite_product.save") signals.post_save.connect(delete_webapp_page_cache, sender=mall_models.ProductCategory, dispatch_uid="termite_product_category.save") post_delete_signal.connect(delete_webapp_page_cache, sender=mall_models.ProductCategory, dispatch_uid="termite_product_category.delete") signals.post_save.connect(delete_webapp_page_cache, sender=mall_models.CategoryHasProduct, dispatch_uid="termite_category_has_product.save") post_delete_signal.connect(delete_webapp_page_cache, sender=mall_models.CategoryHasProduct,
else: return key = 'webapp_owner_info_{wo:%s}' % webapp_owner_id cache_util.delete_cache(key) key_termite_page = 'termite_webapp_page_%s_*' % webapp_owner_id cache_util.delete_pattern(key_termite_page) get_webapp_owner_info(webapp_owner_id) try: from termite2.tasks import purge_webapp_page_from_varnish_cache purge_webapp_page_from_varnish_cache.delay(webapp_owner_id) except: pass post_update_signal.connect(update_webapp_owner_info_cache_with_login, sender=weixin_user_models.MpuserPreviewInfo, dispatch_uid = "mpuser_preview_info.update") signals.post_save.connect(update_webapp_owner_info_cache_with_login, sender=weixin_user_models.MpuserPreviewInfo, dispatch_uid = "mpuser_preview_info.save") post_update_signal.connect(update_webapp_owner_info_cache_with_login, sender=member_models.IntegralStrategySttings, dispatch_uid = "integral_strategy_settings.update") signals.post_save.connect(update_webapp_owner_info_cache_with_login, sender=member_models.IntegralStrategySttings, dispatch_uid = "integral_strategy_settings.save") post_update_signal.connect(update_webapp_owner_info_cache_with_login, sender=member_models.MemberGrade, dispatch_uid = "member_grade.update") signals.post_save.connect(update_webapp_owner_info_cache_with_login, sender=member_models.MemberGrade, dispatch_uid = "member_grade.save") post_update_signal.connect(update_webapp_owner_info_cache_with_login, sender=webapp_models.WebApp, dispatch_uid = "webapp.update") post_update_signal.connect(update_webapp_owner_info_cache_with_login, sender=account_models.UserProfile, dispatch_uid = "user_profile.update") post_update_signal.connect(update_webapp_owner_info_cache_with_login, sender=weixin_user_models.WeixinMpUser, dispatch_uid = "weixin_mp_user.update") #pay interface post_update_signal.connect(update_webapp_owner_info_cache_with_login, sender=mall_models.PayInterface, dispatch_uid = "PayInterface.update") signals.post_save.connect(update_webapp_owner_info_cache_with_login, sender=mall_models.PayInterface, dispatch_uid = "PayInterface.save") post_update_signal.connect(update_webapp_owner_info_cache_with_login, sender=account_models.OperationSettings, dispatch_uid = "OperationSettings.update") signals.post_save.connect(update_webapp_owner_info_cache_with_login, sender=account_models.OperationSettings, dispatch_uid = "OperationSettings.save") signals.post_save.connect(
if isinstance(instance, member_models.Member): try: openid = member_models.MemberHasSocialAccount.objects.filter( member=instance)[0].account.openid delete_member_cache(openid, instance.webapp_id) #get_accounts(openid, webapp_id) except: pass else: instances = list(instance) for member in instances: try: openid = member_models.MemberHasSocialAccount.objects.filter( member=member)[0].account.openid delete_member_cache(openid, member.webapp_id) #get_accounts(openid, webapp_id) except: pass return post_update_signal.connect(update_member_cache, sender=member_models.Member, dispatch_uid="members.update") signals.post_save.connect(update_member_cache, sender=member_models.Member, dispatch_uid="member.save") #signals.post_save.connect(update_webapp_product_cache, sender=mall_models.ProductCategory, dispatch_uid = "product_category.save") #signals.post_save.connect(update_webapp_product_cache, sender=mall_models.CategoryHasProduct, dispatch_uid = "category_has_product.save")