第一次做网页开发 flask 新手 记下一点感想 大家可以吐槽板砖或者指正 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Hualin

第一次做网页开发 flask 新手 记下一点感想 大家可以吐槽板砖或者指正

  •  
  •   Hualin 2013 年 1 月 28 日 4257 次点击
    这是一个创建于 4833 天前的主题,其中的信息可能已经有所发展或是发生改变。
    开发的时候我用 markdown 记录了一点体会,随着时间的推移,其中一些可能是错的。过去没学过任何网页开发的相关技术(我大学是怎么混的??),这次可算是摸着石头过河了,有一些可能是开发常识,我没法找到相关的入门读物,只能靠试琢磨出来一点:

    DEVELOP NOTE
    ===

    # Jan 20 2013
    + in flask, `flask.g` is just something global, which could be refered anywhere like Jinja Template and python project files. It is actually a nothing but a global variable defined in Flask. So just store anything you want there, but do remember the state and reference order of flask.g since it could be changed over time.
    + `endpoint`: Flask itself assumes the name of the view function as `endpoint`.
    + `flask.url_for(endpoint, **values)`, Generates a URL to the given endpoint with the method provided.
    + URL, ENDPOINT and TEMPLATE file name are three different things that are combined together.
    + flask view class is only useful when you need this view to be pluggable to other model or from my understanding now, to other app. sometime it could make things tricky and complex, as the functional view is flexible enough and short.

    # Jan 21 2013
    + Accessing rule of each occupation could be defined for global access control.
    + in flask, `render_template` and `redirect` are not that dramatically different as the names suggest, to me at least, regardless their calling siganiture. (it is wrong)

    # Jan 23 2013
    + the `block` in data base should always remain invisible to users.

    # Jan 27 2013
    + in flask, the HTML is the final view to the user, usually, the develop is view-focusing rather than model-focusing, since it is not a main problem at now. if one HTML view is so much different from another, they should be end up with differnent HTML view, if their logical view share a lot in common, they could share a same view function.
    + flask tries to enforce the opinion that less logic in templates is a good thing.
    + view function should assist jinja to have the logic, it should have all things ready and return them, which is the basic design of `render_template()` calling. thus, a view function should have an 'image' data structure of the corresponding template view.
    + in utility.py query_db and query_db2 are different in return object, the former one returns query object as a dict, while the later one returns a sqlite3.row object. I do not understand the code yet, but the utility function could be used in the future.

    懒得翻译了 有很多语法错误。。。。。。。。。
    8 条回复    1970-01-01 08:00:00 +08:00
    Sherlockhlt
        1
    Sherlockhlt  
       2013 年 1 月 28 日 via iPad
    想问你用什么编辑器写markdown的?
    Hualin
        2
    Hualin  
    OP
       2013 年 1 月 28 日
    @Sherlockhlt 这算是吐槽吗 他哥 我桑心了
    crossmaya
        3
    crossmaya  
       2013 年 1 月 28 日
    这是炫耀英语贴吗?
    scarlex
        4
    scarlex  
       2013 年 1 月 28 日
    本来想看看flask的心得的……结果进来之后一点欲望也没有了……
    想问问楼主学flask多久了?不知道有web开发经验(之前都用django)学flask要多久?
    Sherlockhlt
        5
    Sherlockhlt  
       2013 年 1 月 28 日 via iPad   1
    @Hualin
    非吐槽,真的想知道呢
    Hualin
        6
    Hualin  
    OP
       2013 年 1 月 28 日
    @Sherlockhlt sublime text (windows ) or mou (mac)
    Hualin
        7
    Hualin  
    OP
       2013 年 1 月 28 日
    @crossmaya 我要shi了 你不觉得搞开发用英文做笔记比较方便吗,不用换输入法 杜绝所有乱码 好搜索 好表达?
    Hualin
        8
    Hualin  
    OP
       2013 年 1 月 28 日
    @scarlex 桑心了,快一个月,我加入了一个web app 的项目,有 deadline 和 milestone ,然后逼着自己用 flask
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     5791 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 38ms UTC 02:24 PVG 10:24 LAX 19:24 JFK 22:24
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86