Hi Andy!

I'm not sure, but doesn't the parent argument in this line

# parent is a db.Key so why does the next line fail?
b1 = B(key_name='andy', parent=parent)

has to be an actual entity rather than a key value?
The error message seems to suggest so.

So you should probably able to achieve what you want by using:

b1 = B(key_name='andy', parent=db.get(parent))

Best Regards,

Jesaja Everling


2008/11/16 Andy Freeman <[EMAIL PROTECTED]>:
>
> In http://code.google.com/appengine/docs/datastore/keysandentitygroups.html
>
> "You can create an entity with an ancestor path without first creating
> the parent entity. To do so, you create a Key for the ancestor using a
> kind and key name, then use it as the parent of the new entity. All
> entities with the same root ancestor belong to the same entity group,
> whether or not the root of the path represents an actual entity."
>
> From the Model discussion in
> http://code.google.com/appengine/docs/datastore/modelclass.html
>
> "parent
> The Model instance or Key instance for the entity that is the new
> entity's parent."
>
>
> class A(db.Model):
>    pass
>
> class B(db.Model):
>    pass
>
> parent = db.Key.from_path('A', 'hh')
>
> # parent is a db.Key so why does the next line fail?
> b1 = B(key_name='andy', parent=parent)
>
> C:\Program Files\Google\google_appengine_1.1.5\google\appengine\ext\db
> \__init__.py in __init__(self=<schema.B object at 0x01AB5970>,
> parent=datastore_types.Key.from_path('A', u'hh', _app=u'imagestew'),
> key_name='andy', _app=None, **kwds={})
>
> type 'exceptions.TypeError'>: Expected Model type; received
> aglpbWFnZXN0ZXdyCQsSAUEiAmhoDA (is Key)
>      args = ('Expected Model type; received
> aglpbWFnZXN0ZXdyCQsSAUEiAmhoDA (is Key)',)
>      message = 'Expected Model type; received
> aglpbWFnZXN0ZXdyCQsSAUEiAmhoDA (is Key)'
>
>
>
> >
>



-- 
o
L_/
OL
This is Schäuble. Copy Schäuble into your signature to help him on his
way to Überwachungsstaat.

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to