Reverted model policies to non-parallel version
diff --git a/planetstack/model_policy.py b/planetstack/model_policy.py
index e12b15c..7aef793 100644
--- a/planetstack/model_policy.py
+++ b/planetstack/model_policy.py
@@ -6,6 +6,7 @@
import model_policies
from util.logger import logger
+
modelPolicyEnabled = True
def EnableModelPolicy(x):
@@ -17,7 +18,6 @@
if (d.updated < o.updated):
d.save(update_fields=['updated'])
except AttributeError,e:
- pdb.set_trace()
raise e
def delete_if_inactive(d, o):
@@ -25,6 +25,23 @@
d.delete()
return
+def execute_model_policy(policy_name, instance, update_fields_empty, deleted):
+ if (update_fields_empty):
+ # Automatic dirtying
+ #walk_inv_deps(update_dep, instance)
+
+ try:
+ policy_handler = getattr(model_policies, policy_name, None)
+ logger.error("POLICY HANDLER: %s %s" % (policy_name, policy_handler))
+ if policy_handler is not None:
+ policy_handler.handle(instance)
+ except:
+ logger.log_exc("Model Policy Error:")
+ print "Policy Exceution Error"
+ elif deleted:
+ walk_inv_deps(delete_if_inactive, instance)
+
+
@receiver(post_save)
def post_save_handler(sender, instance, **kwargs):
if not modelPolicyEnabled:
@@ -32,17 +49,13 @@
sender_name = sender.__name__
policy_name = 'model_policy_%s'%sender_name
-
- if (not kwargs['update_fields']):
- # Automatic dirtying
- walk_inv_deps(update_dep, instance)
+ if (not kwargs['update_fields']):
+ noargs = True
+ deleted = False
+ else:
+ noargs = False
+ deleted = True
- try:
- policy_handler = getattr(model_policies, policy_name, None)
- if policy_handler is not None:
- policy_handler.handle(instance)
- except:
- logger.log_exc("Model Policy Error:")
- elif 'deleted' in kwargs['update_fields']:
- walk_inv_deps(delete_if_inactive, instance)
+ execute_model_policy(policy_name, instance, noargs, deleted)
+