Sapan Bhatia | 0235e98 | 2014-09-03 13:14:40 -0400 | [diff] [blame] | 1 | from django.db.models.signals import post_save |
2 | from django.dispatch import receiver | ||||
3 | import pdb | ||||
4 | from model_policies import * | ||||
5 | |||||
6 | @receiver(post_save) | ||||
7 | def post_save_handler(sender, **kwargs): | ||||
8 | sender_name = sender.__name__ | ||||
9 | policy_name = 'model_policy_%s'%sender_name | ||||
10 | try: | ||||
11 | policy_handler = globals[policy_name] | ||||
12 | policy_handler(sender) | ||||
13 | except: | ||||
14 | pass |