This is broken both in SDK and Production.

I filed an issue (link below), but I'd like to know if I'm missing 
something.

#Models

class A(db.Expando):
  foo = db.StringProperty()

class B(db.Expando):
  bar = db.ReferenceProperty(A)


#Saving works fine

...
a = A()
a.foo = "bar"
a.put()

b = B()
b.bar = a
b.put()


#BUT Referencing is broken

...
b = B.all().get()
self.response.out.write(b.bar.foo) #this does not work
self.response.out.write(b.bar.get().foo) #this does not work


#The error message for both is similar and looks like the one below:

Traceback (most recent call last):
  File "C:\Program Files 
(x86)\Google\google_appengine\google\appengine\ext\webapp\_webapp25.py", line 
701, in __call__
    handler.get(*groups)
  File "C:\project\main.py", line 34, in get
    self.response.out.write(b.bar.foo)
  File "C:\Program Files 
(x86)\Google\google_appengine\google\appengine\ext\db\__init__.py", line 1860, 
in __getattribute__
    return super(Expando, self).__getattribute__(key)
  File "C:\Program Files 
(x86)\Google\google_appengine\google\appengine\ext\db\__init__.py", line 3561, 
in __get__
    reference_id.to_path())
ReferencePropertyResolveError: ReferenceProperty failed to be resolved: [u'A', 
u'266']


#Dev or Production?

BOTH.

This bug is also breaking the links in the B entities in the Admin Console 
Datastore Viewer in production. Clicking on the referenced property links, 
present an "entity not found" error.


#Insights

It seems that the resolver method is incorrectly treating the entity id as a 
name, and passing it to the resolver as a string instead of an int or long. I 
did some more tests with db.Key.from_path(), and the output key is different if 
the second argument is a string and if it is an int or long. Perhaps this is 
related to the bug above.



Can someone verify this? Am I missing something?


ISSUE LINK: http://code.google.com/p/googleappengine/issues/detail?id=7170 

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-appengine/-/YmaoTVVxVScJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to