Why do ndb.Model subclasses expand when populated?

We have a model defined as ...

class Foo(ndb.Model): bar = ndb.TextProperty()

If I create or get, an instance Fooand call it Foo, it works ...

foo.populate(**{'SPAM': None})

This gives a Foonew property SPAM.

I would like to know how to make it throw an exception when updating a nonexistent property. I thought this should make it out of the box.

For writing, the new properties are also untyped, so I can do SPAMbe 5, and then "five", without any problems.

+3
source share
3 answers
: " Expando?" , , ndb.Model , .

User - auth, , webapp2_extras.appengine.auth.models, Expando.

, .

TL; DR User webapp2_extras.appengine.auth.models Expando. .

+2

, . , , foo, , bar , . , , . , .

+2

, , TypeError, populate -, , dict. foo.populate(**{"SPAM": None}) foo.populate(SPAM=None)

AttributeError: type object 'Foo' has no attribute 'SPAM'

, ? (, Expando?)

+2

All Articles