翻译
菜单>:
TOC
返回
原文:
* Models: files that contain a description of the data stored by your application. For example the fields in the tables of your databases, their relations, and requirements. web2py tells you which tables are defined in each model file. * Controllers: files that contain the logic of your application. Each URL is uniquely mapped into a function in a controller file. That function can generate a page, delegate a view to render a page, redirect to another URL or raise an exception (depending on the exception that may result in a ticket being issued or in a HTTP error page). web2py tells you which functions are exposed by each controller file. * Views: files that contain HTML and special {{ }} tags which render in HTML variables returned by the controller. This is the presentation layer of your application. web2py tells you when a view extends or imports other views. * Languages: files that contain translation tables for all strings (those that you explicitly mark as language dependent) for any of the languages you want to support. * Static files: all other files, including images, CSS, JavaScript, etc.
翻译:
* Models: 用来描述你的应用程序的数据存储的文件。例如,你的数据库表中的字段、 它们的关系和要求。web2py会告诉你在每个model文件已经定义了哪些表。 *[译注: model.tables?]* * Controllers: 包含你的应用程序处理逻辑的文件。每个URL唯一映射到一个controller 文件的一个函数上。这个函数可以生成页面、委派一个view来渲染一个页面、重定向 到另一个URL或引发一个异常(根据异常的不同,有可能会产生一个ticket或出现在一个 HTTP错误页面中)。web2py会告诉你每个controller文件所暴露出来的函数。 *[译注: 如果在controller中的函数使用``__``开始,如``def __init()``,它将是一个私有 函数,不会被暴露出来,符合Python定义的习惯。]* * Views: 包含HTML和特殊的 {{ }} 标签的文件。这些标签可以在由controller中返回的 变量中进行渲染。这是你的应用程序的展现层。web2py会告诉你何时一个view从其它的 view中进行扩展(extend)或导入。 * Languages: 包含所有你想要支持为其它任一语言的字符串的翻译列表的文件。这些字 符串需要你明确标识为语言依赖。 *[译注:在需要翻译的字符串使用T()函数进行封装。 不过目前好象只能用在controller, view, model中。对于其它的模块好象还不支持。]* * Static files: 其它的所有文件,包括图片、CSS、JavaScript,等等。
备注:
译者: