Yes, you will need to create an entity parent. Note that the more entity
groups you can create, the better performance you will have. See this
document:
http://code.google.com/appengine/docs/python/datastore/keysandentitygroups.html

>From that link:

A good rule of thumb for entity groups is that they should be about the size
of a single user's worth of data or smaller.

On Wed, Nov 11, 2009 at 1:31 PM, Simo Salminen <[email protected]> wrote:

>
> I have database entities that I want to change in transaction. For
> this I have to create an entity group. However, the entities don't
> have any natural parent entity, so I have created a dummy parent
> entity. Is there another good way to do this?
>
> Currently I am using the system below. First, I have following data
> model.
>
> class Event(db.Model):
>    date = db.DateTimeProperty(required=True)
>    name = db.StringProperty(required=True)
>
> I have created a "dummy" parent:
> class Parent(db.Model):
>    pass
>
> Creating parent and defining the parent for the entity (this code is
> inside the transaction):
> try:
>        k = db.get("parent_key")
> except db.BadKeyError:
>        k = models.Parent(key_name="parent_key")
>        k.put()
>
> ancestor_key = k.key()
> q = db.GqlQuery('SELECT * WHERE ANCESTOR IS :1', ancestor_key)
> # (using the query results here, code clipped)
> e = models.Event(date=date, name=name, parent=k)
> e.put()
>
>
> Can I avoid creating this dummy "Parent" model, and satisfy the
> "entity group/transaction" requirement in more elegant way?
>
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<google-appengine%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
>


-- 
Ikai Lan
Developer Programs Engineer, Google App Engine

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
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=.


Reply via email to