I'll show you how to write applications that use CherryPy.
我将说明如何使用CherryPy编写应用程序。
I used the Python/CherryPy server code in Listing 4 (wotd_server.py).
我使用清单4(wotd_server.py)所示的Python/CherryPy服务器代码。
Run this script through Python, and the CherryPy Web server will start up.
通过Python运行这段脚本,CherryPyWeb服务器将会启动。
Cherrypy (import cherrypy) : Minimum version cherrypy 2.1, currently in beta.
cherrypy (import cherrypy):最低版本cherrypy 2.1,目前为be ta版。
One very popular option, and my personal favorite, is CherryPy (see Resources).
一种非常流行的选择,也是我个人最喜欢的,是CherryPy(请参阅参考资料)。
This article introduces CherryPy, a simple but very usable Web framework for Python.
本文将介绍CherryPy,一种用于Python的、简单而又非常有用的Web框架。
Otherwise, CherryPy will never be able to associate two requests with the same session.
否则,CherryPy就永不可能将两个请求与相同的会话关联起来。
Listing 4 is a specialization of the CherryPy Web server presented as Listing 1 of the last article.
清单4是上一期文章中清单1所示的CherryPyWeb服务器的特化。
The CherryPy Web server automatically transforms a URL's query string into a set of keyword arguments.
CherryPyWeb服务器自动将URL的查询字符串转变为一组关键字参数。
The special method default is marked as a CherryPy handler function by the @cherrypy.expose decorator.
default这个特殊方法使用 @cherrypy.expose 修饰符标记为 CherryPy处理程序函数。
Instead of relying on Apache or another Web server, CherryPy runs its own small Python-based Web server.
CherryPy不是依靠Apache或者另外的Web服务器,而是运行它自己的小型的基于Python的Web服务器。
The format of the CherryPy Web server config file and the options you can put into it are described on this Wiki.
CherryPyWeb服务器配置文件的格式及其可放入其中的选项在Wiki中都有描述。
The CherryPy Web site has a basic tutorial, a number of more advanced recipes, and a list of third-party add-ons.
CherryPyWeb站点有一个基本教程、许多比较高级的秘诀。
If cpg.root.hello is a method, CherryPy calls that method, and the output of the method is sent to the Web browser.
如果cpg . root . hello是一个方法,则CherryPy调用该方法,方法的输出被发送到Web浏览器。
Listing 1 (wnserver.py) is a program that USES CherryPy to serve up information about words based on a very simple URL scheme.
清单1 (wnserver . py)是使用CherryPy根据非常简单的URL方案提供单词信息的程序。
When a user hits the /hello/ URL, CherryPy turns any what and the who in the query string into arguments to the hello() method.
当用户点击 /hello/URL 时,CherryPy 将查询字符串中的what和who转换为 hello()方法的参数。
Cherrypy is designed so that this filter on the root handler instance also applies to other handler objects on the chain from cherrypy.root.
根据cherrypy的设计,这个根处理程序实例的筛选器也可用于源自cherrypy .root的链中的其他处理程序对象。
I think the decorator is the best way to expose a method to CherryPy, but you can also expose a method by setting its exposed member to true.
我认为装饰符是将方法暴露给CherryPy的最佳方式,但是也可以通过将其成员exposed设置为True来暴露一个方法。
Unlike frameworks like mod_python that make you mount applications onto URLs served by Apache, CherryPy connects to Apache through rewrite rules.
不像框架(比如mod_python),使您将应用程序安装在Apache提供的URL上,CherryPy通过重写规则而连接到Apache上。
Decorators don't exist in versions of Python prior to version 2.4, so the exposed trick may be the only way for you to expose methods to CherryPy.
装饰符不存在于版本2.4之前的Python中,因而exposed这个技巧可能是您将方法暴露给CherryPy的惟一方式。
Picket (from picket import picket, PicketFilter) : This is a straightforward tool that simplifies the API for invoking XSLT from a CherryPy server.
picket (from picketimport picket,PicketFilter):一种非常简单的工具,简化了从CherryPy服务器中调用XSLT的API。
Instead of serving a Web space rooted in a directory on disk, the CherryPy Web server serves a Web space rooted at a particular Python object, cpg.root.
CherryPyWeb服务器不提供根植于磁盘目录中的Web空间,而提供根植于特定的Python对象cpg . root中的Web空间。
A traditional Web server creates a Web space out of a tree of directories disk, but the CherryPy server creates its Web space out of a tree of Python objects.
传统的Web服务器在目录树磁盘之外创建一个Web空间,而CherryPy服务器则在Python对象树之外创建它的Web空间。
CherryPy USES these informal conventions to eliminate several steps of this process, providing user input as the arguments to the Python method it decides to call.
CherryPy使用这些非正式的约定消除这个过程的几个步骤,以参数的形式将用户输入提供给它决定调用的Python方法。
When you expose an object tree as a CherryPy URL space, the assumption goes the other way: Unless you explicitly label a method as exposed, it isn't served to outside users.
当您将一个对象树暴露为一个CherryPyURL空间时,假设是另一种情形:除非您显性地将方法标记为暴露,否则它不会为外面的用户提供服务。
A well-designed CherryPy class will probably have only a few public methods exposed to Web clients, but it may have many internal methods a client shouldn't be allowed to access directly.
一个设计良好的CherryPy类可能只有少数几个公有的方法暴露给Web客户机,但是它很可能有许多不允许客户机直接访问的内部方法。
The root class sets up a filter, which is a CherryPy construct that performs some action on data that comes in from the HTTP request, and again on data that goes out as the HTTP response.
根类设置了一个筛选器,这是一种CherryPy 结构,对于从HTTP 接收的数据以及 HTTP响应发出的数据执行某些动作。
A CherryPy application method typically returns the body of the response as a string, but sometimes you need to set additional HTTP headers, do a redirect, or change the HTTP response code.
CherryPy应用程序方法通常情况下会以字符串的形式返回响应的正文,但是有时需要您设置附加的HTTP标题,进行一个重定向,或者改变HTTP响应代码。
A CherryPy application method typically returns the body of the response as a string, but sometimes you need to set additional HTTP headers, do a redirect, or change the HTTP response code.
CherryPy应用程序方法通常情况下会以字符串的形式返回响应的正文,但是有时需要您设置附加的HTTP标题,进行一个重定向,或者改变HTTP响应代码。
应用推荐