add --nomodelpolicy option for loading fixtures
Scott Baker [Tue, 21 Oct 2014 22:05:29 +0000 (15:05 -0700)]
planetstack/manage.py
planetstack/model_policy.py
planetstack/scripts/opencloud

index c12bf36..ce14cdb 100644 (file)
@@ -7,4 +7,9 @@ if __name__ == "__main__":
 
     from django.core.management import execute_from_command_line
 
+    if "--nomodelpolicy" in sys.argv:
+        import model_policy
+        model_policy.EnableModelPolicy(False)
+        sys.argv.remove("--nomodelpolicy")
+
     execute_from_command_line(sys.argv)
index ba0cb99..9224c50 100644 (file)
@@ -4,10 +4,19 @@ import pdb
 from core.models import *
 import model_policies
 
+modelPolicyEnabled = True
+
+def EnableModelPolicy(x):
+    global modelPolicyEnabled
+    modelPolicyEnabled = x
+
 @receiver(post_save)
 def post_save_handler(sender, instance, **kwargs):
        sender_name = sender.__name__
        policy_name = 'model_policy_%s'%sender_name
+
+        if not modelPolicyEnabled:
+            return
        
        if (not kwargs['update_fields']):
                try:
index b307e66..7811483 100755 (executable)
@@ -48,7 +48,7 @@ function syncdb {
     python /opt/planetstack/manage.py syncdb --noinput
     if [[ $DJANGO_17 ]]; then
         echo "Loading initial data from fixture..."
-        python /opt/planetstack/manage.py loaddata /opt/planetstack/core/fixtures/initial_data.json
+        python /opt/planetstack/manage.py --nomodelpolicy loaddata /opt/planetstack/core/fixtures/initial_data.json
     fi
 }
 function evolvedb {