I've run into a strange problem that I haven't seen before making a get_by_key_name
call using the App Engine ORM.
Under no circumstances, one would assume, would the following return None:
Model.get_by_key_name(Model.all().get().key().name())
And yet, that's what I've found that certain key names will do. It's only in a few cases where I'm using Open ID URLs like the following as key_name attributes:
https://me.yahoo.com/a/jadjuh3s0klsghiLhtBNbIiHw8k-#3dcl3
(I've changed a couple of chars to protect the innocent)
Maybe the '#' symbol?
Solution: As Nick Johnson suggested, I needed to modify the query since the entity has a parent:
entity = Model.all().get() Model.get_by_key_name(entity.key().name(), parent=entity.parent_key())
Whatever the case may be, if there is a circumstance where a key name can't be used to fetch an entity, then it shouldn't be allowed to be used as a key name in the first place.