tool for making json defaults for xoslib
diff --git a/planetstack/core/xoslib/tools/make_defaults.py b/planetstack/core/xoslib/tools/make_defaults.py
new file mode 100644
index 0000000..5a6a48f
--- /dev/null
+++ b/planetstack/core/xoslib/tools/make_defaults.py
@@ -0,0 +1,40 @@
+import os
+import sys
+os.chdir("/opt/planetstack")
+sys.path.append("/opt/planetstack")
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "planetstack.settings")
+import django
+import core.models
+from django.db import models
+django.setup()
+from django.forms.models import model_to_dict
+import inspect
+from django.core import serializers
+import json
+
+print "function xosdefault() {"
+
+for c in dir(core.models):
+ c = getattr(core.models,c)
+ if inspect.isclass(c) and issubclass(c, models.Model):
+ c=c()
+ classname = c.__class__.__name__
+ classname = classname[0].lower() + classname[1:]
+
+ if (classname in ["plCoreBase", "singletonModel"]):
+ continue
+
+ fieldNames = [f.name for f in c._meta.fields]
+
+ fields = json.loads(serializers.serialize("json",[c],fields=fieldNames))[0]["fields"]
+
+ for f in fields.keys():
+ if f in ['created', 'updated', 'enacted']:
+ fields[f] = None
+
+ fields_json = json.dumps(fields)
+
+ print " this." + classname + " = " + fields_json + ";"
+
+print "};"
+