You can use MyModel(**m_dict), or the following:
m2 = MyModel()
m2.populate(**m_dict)
--
--Guido van Rossum (python.org/~guido)
The problem that I was having was that those two methods didn't work with ndb.StructuredProperty or ndb.LocalStructuredProperty.
BadValueError: Expected ModelClass instance
I believe this can be over come by utilizing the prop._modelclass, I just want to see if anyone else had written this method, before I looked into it more deeply.
- Kyle
That wasn't clear from your post -- while you mentioned
StructuredProperty it didn't occur in your code sample.
> BadValueError: Expected ModelClass instance
This is because to_dict() returns a dict for [Local]StructuredProperty
instead of a Model instance, but the constructor and .propagate()
require Model instances for those.
> I believe this can be over come by utilizing the prop._modelclass, I just want to see if anyone else had written this method, before I looked into it more deeply.
You have presented a use case for from_dict() class method... I've
added a feature request for this to the tracker:
http://code.google.com/p/appengine-ndb-experiment/issues/detail?id=147
--Guido