DAOCLOUD
推荐学习书目
› Python Cookbook
› Using Google App Engine
推荐下载
› Latest Google App Engine SDK
其他兼容技术
› AppScale
Los

重构PB Minisite,200行代码打造自己的minisite

  •  
  •   Los · Oct 26, 2010 · 8291 views
    This topic created in 5852 days ago, the information mentioned may be changed or developed.
    看了一下PB的minisite部分代码,发觉代码量比较多(估摸超过800行)和逻辑上的感觉比较不习惯。习惯rails设计的精简,便尝试着重构一翻,将代码减少到200多行。因为之前没接触过python和GAE,昨晚开发时还需要对python上的Lists(对应ruby上的array)翻资料,所以设计出的代码就可能说不上太符合python的风格了,但在GAE上确实能欢快的跑着。
    后台部分
    http://gist.github.com/raw/646855/5f5388c59705bd390e71884349755ebe00745b2f/backstage.py
    model部分
    http://gist.github.com/raw/646853/78433eda6bfc6b506c34569461bd83409daa11bf/models.py
    17 replies  •  2017-05-11 11:10:04 +08:00
    2014
    2014
    Oct 26, 2010
    3
    Wow! Good job!

    And now the MiniSite can be standalone?
    Los
    Los
    OP
    Oct 26, 2010
    4
    @2014 因为只是尝试着重构PB部分的代码,界面基本就简单copy了一下V2EX的,相当的简陋。
    2014
    2014
    Oct 26, 2010
    6
    @Los 嘿,真的不错。方便就打包一份给亲们下载呀~
    Los
    Los
    OP
    Oct 26, 2010
    7
    @2014 实在不习惯发布一个这么不完善的项目,我再贴出一部分template的代码吧,这样基本就全了。
    http://gist.github.com/646920
    Los
    Los
    OP
    Oct 26, 2010
    9
    还有使用了jquery的js代码
    http://gist.github.com/646928
    Los
    Los
    OP
    Oct 26, 2010
    10
    整个项目代码基本就这个样了,以上。
    2014
    2014
    Oct 26, 2010
    11
    谢谢,收下了。我自己整理下就好了。
    Los
    Los
    OP
    Oct 26, 2010
    12
    一般对errors,在rails上我习惯用hash输出,不过对python的“hash”不熟悉,就偷懒没写。
    Noni
    Noni
    Nov 3, 2010
    13
    这个比重构前好太多了。
    miniairports
    miniairports
    Nov 8, 2010
    14
    mark
    AntiGameZ
    AntiGameZ
    Sep 5, 2011
    15
    哈哈,原来是这个,原来是这个
    ray1980
    ray1980
    Sep 8, 2011
    16
    期待独立版的GAE NOTES
    shreksu
    shreksu
    May 11, 2017
    17
    qw
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2883 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 13:19 · PVG 21:19 · LAX 05:19 · JFK 08:19
    ♥ Do have faith in what you're doing.