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

Reply via email to