views:

28

answers:

1

When the following code is executed:

    q = MyKind.all()
    taskqueue.add(url="/admin/build", params={'cursor': q.cursor()})

I get:

AssertionError: No cursor available.

Why does this happen? Do I need to fetch something first? (I'd rather not; the code is cleaner just to get the query and pass it on.)

I'm using Python on Google App Engine 1.3.5.

+2  A: 

Yes, a cursor is only available if you've fetched something; there's no cursor for the first result in the query.

As a workaround, you could wrap the call to cursor() in a try/except and pass on None to the next task if there isn't a cursor available.

Wooble
.with_cursor(None) is a no-op, so you can indeed simply pass None to the first task.
Nick Johnson