Hi Chris,

You need to specify the parent at creation time. There's no way to modify
the parent of an entity after it's created.

Bear in mind that updates to an entity group are limited to roughly 1QPS -
so putting all your entities in one entity group is rarely a good idea.

-Nick Johnson


On Tue, Jun 15, 2010 at 4:12 AM, Chris Killpack <[email protected]> wrote:

> 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 [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.
>



-- 
Nick Johnson, Developer Programs Engineer, App Engine Google Ireland Ltd. ::
Registered in Dublin, Ireland, Registration Number: 368047
Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number:
368047

-- 
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