wow, I am incredibly stupid. I didn't import the db.Model subclass..
that explains everything. Thanks alot Andy!

Also, for anyone else coming across this thread:

use childTable.all().ancestor(parent_key) to query an entity to find
its parents (instead of querying the parent table for children)

On Mar 18, 11:44 pm, Andy Freeman <ana...@earthlink.net> wrote:
> Did you import the definitions of your db.Model subclasses?  If you
> didn't import the definitions of your db.Model subclasses, there's no
> way for the runtime to build an instance.
>
> db.Model definitions are NOT stored in the datastore.
>
> On Mar 18, 8:21 pm, iceanfire <iceanf...@gmail.com> wrote:
>
>
>
> > anyone?
>
> > On Mar 16, 1:09 pm, iceanfire <iceanf...@gmail.com> wrote:
>
> > > Also, now when I ran the following code in the console:
> > > ========================================
>
> > > from google.appengine.ext import db
>
> > > key_of_specific_Thumb_entity = "agdhcHRydXNochALEgpJbWFnZVRodW1iGEUM"
> > > <<==key grabbed from datastore for thumbnail (which is a parent of the
> > > Bin/Large Image)
>
> > > db.get(db.Key(key_of_specific_Thumb_entity))
>
> > > I get this error:
> > > ============
>
> > > Traceback (most recent call last):
> > >   File "C:\Program Files\Google\google_appengine\google\appengine\ext
> > > \admin\__init__.py", line 194, in post
> > >     exec(compiled_code, globals())
> > >   File "<string>", line 5, in <module>
> > >   File "C:\Program Files\Google\google_appengine\google\appengine\ext
> > > \db\__init__.py", line 1053, in get
> > >     cls1 = class_for_kind(entity.kind())
> > >   File "C:\Program Files\Google\google_appengine\google\appengine\ext
> > > \db\__init__.py", line 217, in class_for_kind
> > >     raise KindError('No implementation for kind \'%s\'' % kind)
> > > KindError: No implementation for kind 'ImageThumb'
>
> > > I'm guessing it has something to do with it being a parent or
> > > something!?
>
> > > On Mar 16, 1:03 pm, iceanfire <iceanf...@gmail.com> wrote:
>
> > > > Hi,
>
> > > > I'm having a bit of trouble understanding how to use parents/children
> > > > properties within transactions.
>
> > > > I have divided up my "Thumbnails" and the actual "Large Image" into
> > > > two separate models to save processing power, but when I upload, I
> > > > want to make sure that both entities are updated--therefore I have to
> > > > use transactions.
>
> > > > Short version (incase the answer is something simple):
> > > > ==========================================
> > > > Can I query to find out the children entities of a Parent entity?
>
> > > > Long Version:
> > > > ===========
> > > > Key fact - thumbnails is connected to the Large Image (bin) via the
> > > > column "bin_id"
>
> > > > The code in Exhibit 1 doesn't work because I get the 'error
> > > > "ImageThumb" must have a complete key before it can be used as a
> > > > parent'. So I tried to:
> > > > 1.  .put() ImageThumb
> > > > 2. assign it as a parent
> > > > 3. .put() Bin (the large image)
> > > > 4. get the ID from step 3
> > > > 5. insert the id in the ImageThumb and .put() it again.
>
> > > > I got the error:  you can't put an entity more than once in appengine!
>
> > > > So my last resort was to just get rid of binID and do steps 1-3. This
> > > > works! But now i'm stuck as to getting the Large Image (child) for a
> > > > specific thumbnail(parent).
>
> > > > Code Exhibit 1
> > > > ======================
> > > > def uploadImages(self):
> > > >                         thumb_db = ImageThumb()
> > > >                         thumb = images.resize(image_data,
> > > > 150,150,images.JPEG)
> > > >                         thumb_db.thumb = db.Blob(thumb)
>
> > > >                         bin_db = ImageBin(parent=thumb_db)
> > > >                         bin_db.image = image_data
> > > >                         bin_put=bin_db.put()
> > > >                         bin_id = bin_put.id()
>
> > > >                         thumb_db.binId = bin_id <<=== need binId so
> > > > that thumbnail is linked to actual image (so I can use get by id
> > > > class)
>
> > > >                         thumb_db.type= "Picture"
> > > >                         thumb_put = thumb_db.put()
> > > >                         thumb_id = thumb_put.id()- Hide quoted text -
>
> > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to