Hi, I have a situation where I need an entity to store a reference to itself, in much the same way as the value of the 'parent' field for the root of an entity group stores it's own key. As with entity groups, its not all records that point to themselves, but some do, and in my use case it means much the same thing - the root of the tree.
The problem is that I also need to create such a record inside a transaction, and transactions have the constraint that you can't update the same record twice. I need to update the record twice - the first time to get the key value generated, and the second time to set that key as the value of the self reference. The most obvious solution is to use a key_name to generate a key without writing to the database, however I will be writing many thousands of these entities, and coming up with my own unique naming process when GAE already has one doesn't seem right. So I guess the first question is whether there is an approach I am missing here. The second would be to find out whether any of the following are likely to make it into GAE anytime soon - 1. Default to self for SelfReference - i.e. pretty much what happens with the 'parent' attribute class Story(db.Model): title = db.StringProperty() selfRef = db.SelfReferenceProperty(default=__self__) 2. A 'self' value when creating a Model instance class Story(db.Model): title = db.StringProperty() selfRef = db.SelfReferenceProperty() s=Story(title="Some title", selfRef="__self__") s.put() 3. Access to the keyFactory key = db.generateKey() s=Story(key_name=key, title="Some title", author="some author") s.selfRef = s.key() s.put() 4. The ability to update the same entity multiple times in the same transaction Thanks, Colin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---