Tornado Documentation
http://www.sunp.eu.org/tornado/
Tornado on GitHub
https://github.com/facebook/tornado/
Tornado Gists
http://tornadogists.org/
qloog
V2EX  ›  Tornado

Tornado 怎么结合 SQLAlchemy 实现分页效果呢

  •  
  •   qloog · Jun 9, 2014 · 9818 views
    This topic created in 4367 days ago, the information mentioned may be changed or developed.
    RT,想在handler中调用model中的方法 实现分页,但是,发现不会写。。。

    求给个示例吧,找了半天没找到,越详细越好(handler、model)
    Supplement 1  ·  Jun 10, 2014
    另外:
    sqlalchemy query回的结果,怎么处理(关键),才能被json_encode呢? 直接json_encode是不行的。
    5 replies    2014-06-10 17:12:19 +08:00
    gkiwi
        1
    gkiwi  
       Jun 9, 2014
    参考这个:http://docs.sqlalchemy.org/en/rel_0_9/orm/query.html#sqlalchemy.orm.query.Query.slice

    slice(start, stop)

    分页无非是往后台多传个pageIdx和pageSize,然后算出start和stop查出数据,传到前台进行渲染.
    hustlzp
        2
    hustlzp  
       Jun 10, 2014
    jamiesun
        3
    jamiesun  
       Jun 10, 2014
    我这有个全套的,评论里有使用说明

    https://gist.github.com/jamiesun/64bcb035e366c4c7fe2d
    jamiesun
        4
    jamiesun  
       Jun 10, 2014
    用的 bootstrap3的 css
    qloog
        5
    qloog  
    OP
       Jun 10, 2014
    @jamiesun 非常感谢,很实用~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3105 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 13:53 · PVG 21:53 · LAX 06:53 · JFK 09:53
    ♥ Do have faith in what you're doing.