阅 读 文 章

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

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


为您的页面建立正确的URL并不是简单的任务,如果您想让页面代码不依靠server名称,端口,webapp名称,前缀。URL是这种形式:http://server:port/serverprefix/webapp/…(server前缀是可选的)。如果您只是用相对url(如 <a href=http://www.chinaunix.net/jh/55/”sub/page.y”>;),那您就不用担心url的基本部分,因为浏览器会自动添加。但是通常最好使用绝对路径(在菜单中,避免嵌套)或者包括 http: 部分的url,和 servername 以及port。您可以将这些数据固定到页面中,但是当他们被改名或者移动到别的webapp中的时候就不能正常工作了。

[list]
Relevant functions相关函数

Ypage:
These are shortcuts to functions defined elsewhere (see the column to the right) to make it easier to use inside an Ypage:这是使用被定义的function的捷径,使得他们在Ypage中使用起来十分容易: 

self.URLprefix
self.Assetprefix
url(path)
asset(path)



for Ypages and Snakelets:
Defined on the Snakelet/Ypage class:在Snakelet/Ypage class中定义的 :

self.getFullURL()
self.getURL()
self.urlescape(str)  # see above, at 'escaping'


Defined on the Webapp: 在webapp中定义的:

wa.getURLprefix()
wa.getAssetprefix()
wa.mkUrl(path)
wa.mkAssetUrl(path)

Defined on the Request object: 在request object中定义的:

req.getRequestURL()
req.getRequestURLplain()
req.getBaseURL()

And perhaps some more (see relevant chapters) 还有其它的(请见相关章节)
[/list]
...explanation not yet written...
...解释说明还没有写...


[size=18]Character encoding: almost a non-issue[/size]

With other web servers, the correct handling of non-ASCII characters or symbols often is a pain. Not with Snakelets. You only have to set the output encoding of your page to the desired encoding (such as UTF-8), and optionally set the input encoding too (if your source file is written in a special character encoding), and Snakelets takes care of all the rest. Don't encode stuff yourself, just write those unicode strings to the page output! If you are careful about the way you add FORMs to your pages (see below), the input of special characters is painless too. Snakelets handles everything and you get to deal with Python strings (or unicode objects) only. All symbols are supported. The suggested character encoding is UTF-8 (it can contain all symbols, is widely supported, and works efficiently for most western languages). You can define a character encoding in every page or define one global setting for all pages using the webapp's defaultOutputEncoding config variable.
论坛热门帖子: [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):国外编程技术书籍,中文编程手册,经典编程文章,交流技术,技术软件下载,计算机论文,毕业论文.