Twisted Web

来自开放百科 - 灰狐
2007年2月22日 (四) 13:28Allen (讨论 | 贡献)的版本

跳转到: 导航, 搜索
Twisted Web's Structure

Twisted Web is a web application server written in pure Python, with APIs at multiple levels of abstraction to facilitate different kinds of web programming.

When the Web Server receives a request from a Client, it creates a Request object and passes it on to the Resource system. The Resource system dispatches to the appropriate Resource object based on what path was requested by the client. The Resource is asked to render itself, and the result is returned to the client.

Main Concepts

  • 'Site Objects' are responsible for creating HTTPChannel instances to parse the HTTP request, and begin the object lookup process. They contain the root Resource, the resource which represents the URL / on the site.
  • 'Resource' objects represent a single URL segment. The IResource interface describes the methods a Resource object must implement in order to participate in the object publishing process.
  • 'Resource trees' are arrangements of Resource objects into a Resource tree. Starting at the root Resource object, the tree of Resource objects defines the URLs which will be valid.
  • '.rpy scripts' are python scripts which the twisted.web static file server will execute, much like a CGI. However, unlike CGI they must create a Resource object which will be rendered when the URL is visited.
  • 'Resource rendering' occurs when Twisted Web locates a leaf Resource object. A Resource can either return an html string or write to the request object.
  • 'Session' objects allow you to store information across multiple requests. Each individual browser using the system has a unique Session instance.

http://twistedmatrix.com/projects/web/

分享您的观点
个人工具
名字空间

变换
操作
导航
工具箱