开发的时候我用 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.
懒得翻译了 有很多语法错误。。。。。。。。。
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/59083
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.