CORD-1053 add create_obj to modelaccessor
Change-Id: If2568a44e0835d62a8b42c626b81caf98bf4b768
diff --git a/xos/synchronizers/new_base/apiaccessor.py b/xos/synchronizers/new_base/apiaccessor.py
index 4ffae57..c721ae1 100644
--- a/xos/synchronizers/new_base/apiaccessor.py
+++ b/xos/synchronizers/new_base/apiaccessor.py
@@ -51,5 +51,8 @@
def get_content_type_id(self, obj):
return obj.self_content_type_id
+ def create_obj(self, cls, **kwargs):
+ return cls.objects.new(**kwargs)
+
diff --git a/xos/synchronizers/new_base/djangoaccessor.py b/xos/synchronizers/new_base/djangoaccessor.py
index b670406..6703ffb 100644
--- a/xos/synchronizers/new_base/djangoaccessor.py
+++ b/xos/synchronizers/new_base/djangoaccessor.py
@@ -80,3 +80,6 @@
def get_content_type_id(self, obj):
return ContentType.objects.get_for_model(obj)
+ def create_obj(self, cls, **kwargs):
+ return cls(**kwargs)
+
diff --git a/xos/synchronizers/new_base/modelaccessor.py b/xos/synchronizers/new_base/modelaccessor.py
index c715095..a7c69bc 100644
--- a/xos/synchronizers/new_base/modelaccessor.py
+++ b/xos/synchronizers/new_base/modelaccessor.py
@@ -82,6 +82,9 @@
def journal_object(self, o, operation, msg=None, timestamp=None):
pass
+ def create_obj(self, cls, **kwargs):
+ raise Exception("Not Implemented")
+
def import_models_to_globals():
# add all models to globals
for (k, v) in model_accessor.all_model_classes.items():
diff --git a/xos/xos_client/xosapi/orm.py b/xos/xos_client/xosapi/orm.py
index 463f2f8..f8bcc63 100644
--- a/xos/xos_client/xosapi/orm.py
+++ b/xos/xos_client/xosapi/orm.py
@@ -336,7 +336,10 @@
def new(self, **kwargs):
cls = self._stub.all_grpc_classes[self._modelName]
- return make_ORMWrapper(cls(), self._stub, is_new=True)
+ o = make_ORMWrapper(cls(), self._stub, is_new=True)
+ for (k,v) in kwargs.items():
+ setattr(o, k, v)
+ return o
class ORMModelClass(object):
def __init__(self, stub, model_name, package_name):