I am getting what appears just like a very strange trouble with an Entity relationship within the google application engine data store. I am focus on a Python/GAE webapp (learning exercise), the entire code to that exist on sourceforge.

  • I've 2 models:
    • Gallery - searching term and (not directly) a listing of photos
    • Photo - details about a photograph, as well as the gallery it goes to (collection_index='photos')
  • I've an ingestion procedure that produces art galleries and adds photos for them
  • I've got a page that reads a gallery in the datastore and uses the ".photos" attribute of this Gallery instance to obtain the listing of photos inside it

Now this is when the strange part is available in... Basically change personal files (any file I have examined on) as well as just update the timestamp from the file (ie, therefore it will get reloaded)... the ".photos" attribute of art galleries begins failing. For instance, basically attempt to load the page for the "flowers" gallery:

Traceback (most recent call last):
  File "C:\Applications\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 700, in __call__ handler.get(*groups)
  File "C:\Eclipse-Workspace\galleries-google\app\views\gallery.py", line 33, in get for photo in gallery.photos:
AttributeError: 'Gallery' object has no attribute 'photos'

I'm able to restart the webapp, I'm able to restart the application launcher after which start the webapp. The issue continues no matter this. It appears I have to pressure the datastore to "remember" the bond in some manner

# Reading the list of photos for a given gallery via the Photo entity
# This seems to force the datastore to "remember" the connection between the two
from google.appengine.ext import db
import pprint
from app.models.gallery import Gallery
from app.models.photo import Photo

gallery = Gallery.get_by_key_name('candy')
print("Gallery: " + gallery.search_term)
q = db.GqlQuery("SELECT * FROM Photo WHERE gallery = :1", gallery )
photos = q.fetch(20)

for photo in photos :
    print("\tphoto: " + photo.getUrl('original'))

or by re-consuming all of the data on your own (though I guess simply re-consuming just one gallery would do).

Does anybody have ideas in regards to what may be leading to this? Any help could be appreciated.


  • This is incorporated in the dev atmosphere. I've not become to the stage where it's worth signing up it as being a webapp around the real servers yet.
  • Strangely enough, I lately requested an issue regarding how to How to list child nodes in parent in GAE... since i have wanted the data to appear in parents model definition. Ironic it's (apparently) deficiencies in that information within the parent that's leading to an issue now