I am  running into a confusing "can't operate on multiple entity groups in a 
single transaction" case when I am, in fact, not accessing "multiple entity 
groups". I think I understand what might be going on, but A) am not certain and 
B) others might find it interesting, anyway.

What is happening is that I have a transaction that is operating over two 
models: GoogleUser and Account. I get the GoogleUser instance associated with 
the current e-mail address with get_by_key_name and then return gooser.account. 
If I fail to find that GoogleUser, I add a new Account, and into the /same 
entity group/ I add the GoogleUser in question.

For reference, here is the actual code of my transaction:

    132     @staticmethod
    133     def goi_account_by_primary_key_(user, hash, **kw):
    134         gooser = GoogleUser.get_by_key_name(hash)
    135         if gooser:
    136             account = db.get(gooser.account)
    137             keys = kw.keys()
    138             for key in keys:
    139                 setattr(account, key, kw[key])
    140             account.put()
    141         else:
    142             account = Account(**kw)
    143             account.put()
    144             gooser = GoogleUser(parent=account, key_name=hash, 
user=user, account=account)
    145             gooser.put()
    146         return account

Note that moving the creation of the gooser above the creation of the account 
(and swapping the parent/child relationship between them and making other 
required code changes to temporarily support that) does work.

Why does this happen?

Currently my two theories are: A) the detection code is incorrect, and is 
making assumptions about "same model", and B) entities that don't exist yet are 
only considered in the same entity group as that entity itself, so even though 
I'm going to create that entity later into the same entity group, I can't put a 
different object first as the data store can't tell the difference. I am 
guessing that B is correct, in which case maybe someone else working on this 
same problem will find this post and be helped by it. If it isn't B, then maybe 
someone would be kind enough to tell me what the problem actually is ;P.

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

Reply via email to