History of CherryPy

Remi Delon released the first version of CherryPy in late June 2002. This was the starting point of a successful Python web library. Remi is a French hacker who has trusted Python for being ultimately one of the greatest alternatives for web application development. The project attracted a number of developers who were interested in the approach taken by Remi CherryPy classes were an extension to Python to support the separation of concern between the data and the presentation. It was close to...

Installation from Subversion

Subversion is often viewed as the successor of CVS and is considered much friendlier. However, other revision systems also exist such as Monotone or Darcs. Under Linux, you can either install Subversion from its sources or using a package manager. Let's describe the procedure for the source code. 1. Get the latest tarball from http subversion.tigris.org 2. Then type the following command in the command console tar zxvf subversion-x.y.z.tar.gz 3. Enter the newly created directory and type ....

Unit Testing Web Applications

In the previous section, we have presented two standard modules to perform unit testing in Python applications and packages. Unfortunately as they stand they lack some common features to help in specific contexts such as web applications. The Python community has obviously come up with solutions and there are several good extensions to unittest or completely distinct test packages to help us. We will use an extension to unittest, provided by CherryPy, called webtest and developed by Robert...

Error and Exception Handling

CherryPy tries hard to help the developer see a web application as close as a rich application. This means that from your page handler you may raise a Python error or exception as in any other Python application. CherryPy will catch those and transform them into HTTP messages depending on the type of errors. Note that when an exception is raised and not caught by any other part of the application, CherryPy will return the corresponding HTTP 500 error code. For example, the following example...

Hook into Cherry Pys Core Engine

Call Handling Process

One of the most powerful aspects of CherryPy is how its core lets you modify its normal behavior with a very fine granularity. Indeed, CherryPy offers a mechanism called hooking to customize the core engine. A hook is an entry point for Python callables to be applied at specific points during the request processing. CherryPy provides the following entry points Called at the beginning of the process. Called before CherryPy tries to read the request body. It allows a tool to inform CherryPy...

Application under Test

Before we explain how Selenium components work, we must introduce an application example. This application will simply provide one web page with two links. One of them will replace the current page with a new one. The second link will fetch data using Ajax. We use this example rather than our photoblog application for the sake of simplicity. The code of the application is as follows _header lt html gt lt head gt lt title gt Selenium test lt title gt lt head gt lt script type application...

Authentication using Digest or Basic Schemes

The open method of XMLHttpRequest can take username and password parameters to be sent along with the request. The authentication schemes supported by XMLHttpRequest are defined in RFC 2617, namely basic and digest. These two schemes are as follows Basic scheme The basic scheme is simply the transfer of the username and password encoded using the base64 algorithm. The issue with this is that, if a third-party fetches the encoded value, nothing can be done to prevent it from being decoded. This...