views:

32

answers:

1

I am having trouble with one specific query. It needs to run in a transaction, and it does, but whenever the app engine executes my query I get the following error:

Only ancestor queries are allowed inside transactions

You'll see that my query DOES have an ancestor. So what is the app engine really complaining about?

    q = db.Query(EventBase)
    q.ancestor = db.Key.from_path(aggrRootKind, aggrRootKeyName)
    q.filter('undone =','False')
    q.order('-version')
    qResult = q.fetch(1, 0)
+2  A: 

This line:

q.ancestor = db.Key.from_path(aggrRootKind, aggrRootKeyName)

should read:

q.ancestor(db.Key.from_path(aggrRootKind, aggrRootKeyName))

ancestor() is a method, and in the first snippet, you're replacing it, rather than calling it.

Nick Johnson
ARG, silly me. I keep doing that. Thanks for pointing out my mistake :)
willem