为您的页面建立正确的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.
上一页 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 2223 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 下一页
| 论坛热门帖子: | [lch203] 写得蛮好的linux学习笔记(10-21) [黑马制造] 学习java的30个目标(10-19) [笑傲股林] 做测试半年了,有点迷茫,应该再学些什么提高自己的测试水平和测试能力呢?(10-19) [udp8589] 大家用google的来吱一声? 用百度的~~也来报道下?(10-18) [沂偌掳兆] 本人总结的一些认为C++比较经典的书籍,希望对大家有用(10-18) |
| TAG标签: | 翻译 文档 使用 可以 页面 URL 如果 文件 webapp 一个 |
注册
个人空间
