def distill_model_event(instance, model, action, user_override=None): """ Take created, updated and deleted actions for built-in app/model mappings, convert to the defined event.name and let hooks fly. If that model isn't represented, we just quit silenty. """ from rest_hooks.models import HOOK_EVENTS event_name = None for maybe_event_name, auto in HOOK_EVENTS.items(): if auto: # break auto into App.Model, Action maybe_model, maybe_action = auto.rsplit('.', 1) maybe_action = maybe_action.rsplit('+', 1) if model == maybe_model and action == maybe_action[0]: event_name = maybe_event_name if len(maybe_action) == 2: user_override = False if event_name: finder = find_and_fire_hook if getattr(settings, 'HOOK_FINDER', None): finder = get_module(settings.HOOK_FINDER) finder(event_name, instance, user_override=user_override)
def distill_model_event(instance, model, action, user_override=None): """ Take created, updated and deleted actions for built-in app/model mappings, convert to the defined event.name and let hooks fly. If that model isn't represented, we just quit silenty. """ from rest_hooks.models import HOOK_EVENTS event_name = None for maybe_event_name, auto in HOOK_EVENTS.items(): if auto: # break auto into App.Model, Action maybe_model, maybe_action = auto.rsplit('.', 1) if model == maybe_model and action == maybe_action: event_name = maybe_event_name if event_name: find_and_fire_hook(event_name, instance, user_override=user_override)
def distill_model_event(instance, model, action, user_override=None): """ Take created, updated and deleted actions for built-in app/model mappings, convert to the defined event.name and let hooks fly. If that model isn't represented, we just quite silenty. """ from rest_hooks.models import HOOK_EVENTS event_name = None for maybe_event_name, auto in HOOK_EVENTS.items(): if auto: # break auto into App.Model, Action maybe_model, maybe_action = auto.rsplit('.', 1) if model == maybe_model and action == maybe_action: event_name = maybe_event_name if event_name: find_and_fire_hook(event_name, instance, user_override=user_override)