V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
DAOCLOUD
推荐学习书目
Python Cookbook
Using Google App Engine
推荐下载
Latest Google App Engine SDK
其他兼容技术
AppScale
Los

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

  •  
  •   Los · Oct 26, 2010 · 7655 views
    This topic created in 5667 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
    Los
        1
    Los  
    OP
       Oct 26, 2010
    Los
        2
    Los  
    OP
       Oct 26, 2010
    2014
        3
    2014  
       Oct 26, 2010
    Wow! Good job!

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