I want to get a entity through a ReferencePropery in this way.
getattr(model, refrence)
where model is a db.Model
and reference is db.ReferenceProperty
. But I get a KindError, which I can avoid by adding import of following sort.
from foomodule import ReferedKind
Where ReferedKind
is the class of the entity I want to get by above getattr
.
But my problem is in my case because of the nature of the function I want to call this in, the model
can belong to any Model class of mine. So I don't know what the ReferedKind
will be.
How can I call getattr
and get the referred entity without importing every possible model class?
Is there a way I can know the class of a entity referred by a ReferanceProperty
in advance so I can dynamically import it?
Aditional info
I am writing a function that would return a json serializable python dict. Because in some cases dictionary returned by db.to_dict() is not json serializable. So the function doesn't know in advance what kind of a model it will have to put into a dict.