I have a set of entities all of the same kind, AnalyticsCounter, in my datastore. For correctness I would like to update many of these entities in a single transaction, which requires they are all in the same entity group. In my case I don't have a hierarchy, instead I just have a set of entities. My understanding is that I need to parent all of them to another AnalyticsCounter entity to achieve this. However when I tried this, I received the fateful "Cannot operate on different entity groups in a transaction error.".
I created the parent entity in my constructor, and then applied the parent when I created an instance of AnalyticsCounter, but the transaction fails on the put method. Interestingly the "different entity groups" lists both the newly created instance and the parent instance. I tried creating the parent two different ways, first just creating a key: self._parent_key = db.Key.from_path('AnalyticsCounter', 'virtual_root') and then, creating an actual instance. self._parent_instance = AnalyticsCounter.get_or_insert(key_name='root') but met the same failure on both cases. Briefly, my transaction looks like this: counters = [list of key_names] def txn(): counters = AnalyticsCounter.get_by_key_name(counters) for counter in counters: if counter is None: counter = AnalyticsCounter(parent=self._parent_instance, key_name='blah') counter.foo = 'bar' counter.put() # <- dies here db.run_in_transaction(txn) Can someone shed some light on what I am doing wrong? Thanks, Chris -- 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-appeng...@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.