In Ypages you have some shortcuts to easily obtain the current URL prefix and so on. From a Snakelet, you can do exactly that but not directly: you have to get the webapp first using getWebApp() and use its methods instead. The webapp object also has two convenient methods to create urls: mkUrl and mkAssetUrl!
在Ypage中有一些很方便的捷径来获得URL前缀。对于Snakelet,您可以或者前缀,但是没有这么直接:您必须先使用getWebApp()得到webapp。Webapp对象有两个很方便的方法用来创建url:mkUrl 和 mkAssetUrl !
[size=18]Using self in Snakelets to store data[/size]
Short: you shouldn't. Long: your Snakelet code has no single, local, 'personal', environment it is running in. There is only one object (instance) of your Snakelet and it might be accessed concurrently by multiple threads. Only use local objects to store temporary data in, never create new properties on self! If you really need to store some data that is local for this Snakelet, and shared for all users and all requests, you can use the getContext() method to obtain the local Snakelet data context.
您的Snakelet代码不能在单独的,独立的,’个人’的环境中运行。这里只有一个Snakelet对象,他们可能同时被多个线程访问。仅仅使用本地对象来存储临时数据,但并不在self上创建新的属性!如果您想存储并共享本地数据和所有请求数据,您可以使用getContext() 方法获得当前Snakelet数据。
[size=18]Making a download snakelet that serves static file content[/size]
Use self.getWebApp().serveStaticFile(filename, response, useResponseHeaders=False) to utilize the server's own internal code to serve static files efficiently. See the webapp chapter.
使用 self.getWebApp().serverStaticFile(filename, response, useResponseHeaders=False) 来利用server内部自有代码有效的提供静态文件服务。见webapp章节。
瘦青蛙 回复于:2005-06-27 11:55:17
[size=18]Request Object[/size]
Your snakelet gets the current request and response objects in the serve method, and you can do lots of stuff with them:
从server方法中得到的request 对象可以使用的方法和属性:
上一页 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2728 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 一个 |
注册
个人空间
