阅 读 文 章

snakelets 文档,我翻译了一部分。

[来源:网上转载 (http://www.chinaunix.net) | 作者:网友(瘦青蛙) | 时间:2007-05-27 | 浏览:人次 ]



A more advanced way is to use inheritance to let your Ypage inherit from another Ypage or even from a custom Python class. You can put common code in the base Ypage or class and let multiple pages inherit from it, so that they will share the code. It is possible to let the base Ypage handle the page creation (and refer to the inherited page) by using the pagemethod declaration. 
更高级的方法是 继承,也就是使你的Ypage继承其他 Ypage或者其他的python 类。您可以将公共代码放到基本Ypage或者 class中,然后让其他页面继承他们。通过使用pagemethod声明可以让基础Ypage控制页面创建。

Ypages and Snakelets are essentially just Python classes so you an import and use other modules and classes just like you would otherwise do to structure your Python program. Put common code and/or code that is not related to the actual page content in a different module, and import that in your Ypage/Snakelet, so that the rest of the code can stay concise and clean. Use subdirectories to divide and group related pages (just as you would use packages in regular Python code).
Ypage和 Snakelet 基本上是Pyhton 类,所以您可以像编写Python程序一样调用module或者 class。可以在与正是页面无关的module中编写公共代码/代码,并通过import来引用到您的 Ypage/Snakelet中,这样编写代码十分简洁。使用子目录来分离和聚合有联系的页面(就像在python中使用package)。

[size=18]HTML- and URL-escaping[/size]

Some characters are invalid inside HTML (such as <, >;, & and "). If you generate HTML, you have to make sure that you escape (also called quote) those special characters. You should use the self.escape(text) method for this. Escaping is only needed at the place where you actually want to output the text on the page.
一些字符在HTML中是无效的(比如 <, >;, & , “)。如果您生成一个HTML,您必须确定您将这些特殊符号escape(也叫 引)起来。您可以使用self.escape(text)方法来实现。Escaping 只需要放置你在页面中想要输出的文本。
论坛热门帖子: [lch203] 写得蛮好的linux学习笔记(10-21)
[黑马制造] 学习java的30个目标(10-19)
[笑傲股林] 做测试半年了,有点迷茫,应该再学些什么提高自己的测试水平和测试能力呢?(10-19)
[udp8589] 大家用google的来吱一声? 用百度的~~也来报道下?(10-18)
[沂偌掳兆] 本人总结的一些认为C++比较经典的书籍,希望对大家有用(10-18)
TAG标签: 翻译 文档 使用 可以 页面 URL 如果 文件 webapp 一个

最新评论 共有1位网友发表了评论

发表评论

评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名:(注册)
密码:
验证码:
匿名发表

网站地图友情连接交流论坛网站投稿广告服务联系我们留言本站长统计
Some rights reserved: www.chmhome.com, 鄂ICP备07010232号 E-mail:chinakafei@live.com,QQ:552766
中国咖啡技术网(Chmhome):国外编程技术书籍,中文编程手册,经典编程文章,交流技术,技术软件下载,计算机论文,毕业论文.