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

2013-01-28 20:59:14 +08:00
 Hualin
开发的时候我用 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.

懒得翻译了 有很多语法错误。。。。。。。。。
3605 次点击
所在节点    Python
8 条回复
Sherlockhlt
2013-01-28 22:26:10 +08:00
想问你用什么编辑器写markdown的?
Hualin
2013-01-28 22:28:15 +08:00
@Sherlockhlt 这算是吐槽吗 他哥 我桑心了
crossmaya
2013-01-28 22:30:14 +08:00
这是炫耀英语贴吗?
scarlex
2013-01-28 22:34:41 +08:00
本来想看看flask的心得的……结果进来之后一点欲望也没有了……
想问问楼主学flask多久了?不知道有web开发经验(之前都用django)学flask要多久?
Sherlockhlt
2013-01-28 22:39:01 +08:00
@Hualin
非吐槽,真的想知道呢
Hualin
2013-01-28 22:54:46 +08:00
@Sherlockhlt sublime text (windows ) or mou (mac)
Hualin
2013-01-28 22:55:47 +08:00
@crossmaya 我要shi了 你不觉得搞开发用英文做笔记比较方便吗,不用换输入法 杜绝所有乱码 好搜索 好表达?
Hualin
2013-01-28 22:57:49 +08:00
@scarlex 桑心了,快一个月,我加入了一个web app 的项目,有 deadline 和 milestone ,然后逼着自己用 flask

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/59083

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX