python – 与谷歌应用程序引擎分页

python – 与谷歌应用程序引擎分页,第1张

概述我有几个关于如何与gae进行分页的问题.测试代码: for i in range(0, 6): MyClass(myProperty=unicode(i)).put() q = MyClass.all() cursor = None print haveMore = True batchSize = 2 i = 1 while 我有几个关于如何与gae进行分页的问题.测试代码:

for i in range(0,6):        MyClass(myProperty=unicode(i)).put()    q = MyClass.all()    cursor = None    print    haveMore = True    batchSize = 2    i = 1    while haveMore:        print 'Batch',i        i = i + 1        result_set = q.with_cursor(start_cursor=cursor).fetch(batchSize)        for obj in result_set:            print obj.myProperty        cursor = q.cursor()        print cursor        haveMore = True if len(result_set) == batchSize else False

输出:

Batch 101E9oBTgoMdGVzdGJlZC10ZXN0GgdNeUNsYXNzIUNVulNPUiFqHWoMdGVzdGJlZC10ZXN0cg0LEgdNeUNsYXNzGaimggENCxIHTXlDbGFzcxgCDOABABQ=Batch 223E9oBTgoMdGVzdGJlZC10ZXN0GgdNeUNsYXNzIUNVulNPUiFqHWoMdGVzdGJlZC10ZXN0cg0LEgdNeUNsYXNzGAQMggENCxIHTXlDbGFzcxgEDOABABQ=Batch 345E9oBTgoMdGVzdGJlZC10ZXN0GgdNeUNsYXNzIUNVulNPUiFqHWoMdGVzdGJlZC10ZXN0cg0LEgdNeUNsYXNzGAYMggENCxIHTXlDbGFzcxgGDOABABQ=Batch 4

问题:

>首先,当在for循环的不同迭代中使用相同的游标时,结果集如何推进?
>如何修复边缘情况? for循环应在3次迭代后终止.批次4为空.
>如何在gae中反向翻页(即返回而不是下一个)?

解决方法 看看这里 Query with paging by cursor causes error because of limitations for “IN filter” in cursor() method… What should be the alternative? 总结

以上是内存溢出为你收集整理的python – 与谷歌应用程序引擎分页全部内容,希望文章能够帮你解决python – 与谷歌应用程序引擎分页所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/langs/1196484.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-06-03
下一篇2022-06-03

发表评论

登录后才能评论

评论列表(0条)

    保存