CherryPy Essentials: Rapid Python Web Application Development

CherryPy Essentials: Rapid Python Web Application Development
eBook: $23.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 30%!
Print + free eBook + free PacktLib access to the book: $63.98    Print cover: $39.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • Walks through building a complete Python web application using CherryPy 3
  • The CherryPy HTTP:Python interface
  • Use CherryPy with other Python libraries
  • Design, security, testing, and deployment

Book Details

Language : English
Paperback : 272 pages [ 235mm x 191mm ]
Release Date : March 2007
ISBN : 1904811841
ISBN 13 : 9781904811848
Author(s) : Sylvain Hellegouarch
Topics and Technologies : All Books, Web Development, Content Management (CMS), Open Source

Table of Contents

Chapter 1: Introduction to CherryPy
Chapter 2: Download and Install CherryPy
Chapter 3: Overview of CherryPy
Chapter 4: CherryPy in Depth
Chapter 5: A Photoblog Application
Chapter 6: Web Services
Chapter 7: The Presentation Layer
Chapter 8: Ajax
Chapter 9: Testing
Chapter 10: Deployment
  • Chapter 2: Download and Install CherryPy
    • Requirements
    • Overview
    • Installation from a Tarball
    • Installation through Easy Install
    • Installation from Subversion
    • Testing your Installation
    • Keeping CherryPy Up to Date
    • Summary
  • Chapter 3: Overview of CherryPy
    • Vocabulary
    • Basic Example
    • Built-In HTTP Server
    • Internal Engine
    • Configuration
    • Object Publisher Engine
    • Library
      • The Autoreload Feature
      • The Caching Module
      • The Coverage Module
      • The Encoding/Decoding Module
      • The HTTP Module
      • The Httpauth Module
      • The Profiler Module
      • The Sessions Module
      • The Static Module
      • The Tidy Module
      • The Wsgiapp Module
      • The XML-RPC Module
    • Tools
    • Error and Exception Handling
    • Summary
  • Chapter 4: CherryPy in Depth
    • HTTP Compliance
    • Multiple HTTP Servers
    • Multi-Threaded Application Server
    • URI Dispatching
      • HTTP Method Dispatcher
      • Routes Dispatcher
      • Virtual Host Dispatcher
    • Hook into CherryPy's Core Engine
    • CherryPy Toolbox
      • Basic Authentication Tool
      • Caching Tool
      • Decoding Tool
      • Digest Authentication Tool
      • Encode Tool
      • Error Redirect Tool
      • Etag Tool
      • Gzip Tool
      • Ignore Headers Tool
      • Log Headers Tool
      • Log Tracebacks Tool
      • Proxy Tool
      • Referer Tool
      • Response Headers Tool
      • Trailing Slash Tool
      • XML-RPC Tool
      • Toolbox
      • Creating a Tool
    • Static Resource Serving
      • Using the Staticfile Tool to Serve a Single File
      • Using the Staticdir Tool to Serve a Complete Directory
      • Bypassing Static Tools to Serve Static Content
    • WSGI Support
      • Hosting a WSGI Application within the CherryPy WSGI Server
      • Hosting a CherryPy WSGI Application within a Third-Party WSGI Server
    • Summary
  • Chapter 5: A Photoblog Application
    • A Photoblog Application
    • Photoblog Entities
    • Vocabulary
    • DBMSes Overview
      • Relational Database Management System (RDBMS)
      • Object-Oriented Database Management System (OODBMS)
      • XML Database Management System (XMLDBMS)
    • Object-Relational Mapping
      • Python Object-Relational Mappers
    • Photoblog Application Entity Modeling
      • Mapping Entities
      • Units and UnitProperties
      • Associating Units
      • The Sandbox Interface
    • Querying Units
    • Extending the Data Access Layer
    • Summary
  • Chapter 6: Web Services
    • Traditional Web Development
      • Separation of Concerns
    • REST
    • Uniform Resource Identifier
    • HTTP Methods
    • Putting it Together
    • REST Interface through CherryPy
    • Atom Publishing Protocol
    • Atom XML-Document Format
    • APP Implementation
    • Summary
  • Chapter 7: The Presentation Layer
    • HTML
    • XML
    • XHTML
    • CSS
    • DHTML
    • Templating
    • Kid—The Templating Engine
      • Overview
      • Kid's Attributes
        • XML-Based Templating Language
        • Variable Substitution
        • Conditional Statement
        • Looping Mechanism
        • Extensibility
        • Other Attributes
    • Photoblog Design Preparation
      • Targetting the User Agent
      • Tools
      • Global Design Goals
      • Design Directory Layout
      • CherryPy—Encapsulating the Template Rendering Process
    • Photoblog Design in Detail
      • Basic Structure
    • Mochikit
    • Developing the Photoblog Design
      • HTML Code
      • Adding a Link
      • Handling the End-User Actions
      • Amending the Template
      • Amending the CSS
      • Let's be More Flexible...
    • Summary
  • Chapter 8: Ajax
    • Rise of the Rich-Client Applications
    • Ajax
      • Ajax—Advantages and Drawbacks
      • Behind the Scene: XMLHttpRequest
        • Performing a GET Request
        • Performing a Content-Negotiated GET Request
        • Performing a POST Request
        • Performing PUT, HEAD, or DELETE Requests
        • Cookies
        • Authentication using Digest or Basic Schemes
    • JSON
    • Applying Ajax to our Application
      • Defining the Required Namespaces
      • Implementing Namespaces
      • Adding Methods to the Classes
      • Method to Create a New Album
      • Method to Update an Existing Album
      • Method to Delete an Existing Album
    • Summary
  • Chapter 9: Testing
    • Why Testing
    • Planning a Test
    • Common Testing Approach
    • Unit Testing
      • unittest
      • doctest
    • Unit Testing Web Applications
    • Performance and Load Testing
    • Functional Testing
      • Application under Test
        • Selenium Core
        • Selenium IDE
        • Selenium Remote Control
    • Summary
  • Chapter 10: Deployment
    • Configuration
      • CherryPy—Web and Engine Configuration System
      • Photoblog Application Configuration System
    • Deployment
      • Apache with mod_rewrite Module
      • Lighttpd with mod_proxy Module
      • Apache with mod_python Module
      • mod_python with WSGI Application
    • SSL
      • Creating a Certificate and a Private Key
        • Using the CherryPy SSL Support
        • Using the lighttpd SSL Support
        • Using the Apache mod_ssl Support
    • Summary

Sylvain Hellegouarch

Sylvain Hellegouarch is an IT Software Consultant dedicated to the development of free software projects such as CherryPy. Since 2004 he has been coordinating and administrating the community efforts around the project providing support for newcomers and seasoned developers, alike. In 2006 he developed 'bridge' and 'amplee', two Python-based projects centered on XML and the upcoming Atom Publishing Protocol respectively. He has also been deeply involved in The Viberavetions Project, a comprehensive grassroots solution for independent artists and musicians to better connect with consumers, as well as the nuXleus project, a platform designed for faster, more reliable inter and intra application and personal communication. Born in France, Sylvain graduated with a degree in Computer Science from South Brittany University, Vannes, France in 2002. Since then he has been working as an IT consultant for a variety of companies, both small and large. He currently resides in the United Kingdom.

Contact Sylvain Hellegouarch

Code Downloads

Download the code and support files for this book.

Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


- 1 submitted: last submission 02 Aug 2013

Errata type: Typo | Page number: 0

In the IP address replace "1102.168" with "192.168", throughout the book.


Errata type:Code | Page number:14

The default directories where packages and modules are stored are: On MacOS --- begin is --- Python:Lib:site-packages --- end is --- --- begin should be --- /Library/Python/2.5/site-packages --- end should be ---


Errata type:Code | Page number:52

'Multiple HTTP Servers' section is now obsolete. Check out at- Ticket #752 (defect) Return cherrypy.server to a single-server model Changeset 1822 Timestamp: 11/10/07 19:37:41 Author: fumanchu Changeset 1824 Timestamp: 11/11/07 13:47:09 Author: fumanchu


Errata type: Typo | Page number: 53

Use the IP addresses "" & "" instead of the IP addresses mentioned in the book.


Errata type: Typo | Page number:53

Replace the port number "100100" with "10100".


Errata type: Typo | Page number: 63

Replace the digest 'a104a8fe5ccb110ba61c4c0873d3101e10871082fbbd3' with 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3'.


Errata type:Typo | Page number: 77

In the third paragraph, under "Creating a tool", replace "using the ElementTree library" with "using the ElementTree and Amara libraries".


Errata type: Typo | Page number: 96

Replace "There is no RDBMS written in Python but most RDBMSes can be accessed via a corresponding Python library." with "Most RDBMSes can be accessed via a corresponding Python library."


Errata type: Code | Page number: 177

dejsonifier tool doesn't work if the content-type contains aditional values like: application/json; charset=UTF-8. So I suggest to replace the line: if cherrypy.request.headers['content-type'] == 'application/json: to: if u'application/json' in cherrypy.request.headers['content-type']:


Errata type: Typo | Page number: 236

In the final code snippet, replace 'tools.staticfilE.file' with 'tools.staticfile.file'.


Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

CherryPy Essentials: Rapid Python Web Application Development +    MySQL for Python =
50% Off
the second eBook
Price for both: $37.50

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • The book will be about CherryPy 3
  • CherryPy installation using the tarball, egg, and subversion
  • The CherryPy library in depth: its design and how to use it
  • Using CherryPy with common Python and non-Python products
  • Object Relational Mapping with SQLObject, SQLAlchemy, and Dejavu
  • Web Services via REST and the Atom Publishing Protocol
  • AJAX and client-side scripting via MochiKit
  • Unit, functional, and load testing
  • CherryPy, Apache, and lighttpd deployment solutions

In Detail

CherryPy is a Python library for web development that allows developers to build web applications in the same way as any other object-oriented Python program. Enriched by several years of active development, it has become one of the most established toolkits for building solid and high-performance web applications in Python. CherryPy abstracts the complex low-level HTTP protocol into an easy-to-use interface that respects Python idioms. The library aims at being simple to learn for a beginner while offering the most advanced features to fluent Python developers. For these reasons CherryPy was chosen to be at the heart of the popular and feature-rich TurboGears web framework. CherryPy-powered web applications are stand-alone Python applications with their own embedded multi-threaded web server, but can also run behind Apache or IIS for scalability.

This book covers the CherryPy library for Python web development from its history and installation through its main features and core concepts to its integration with Python and other products to construct, test, and deploy a sample photoblog application. The author Sylvain Hellegouarch is dedicated to the development of free software projects and has been coordinating and administrating the community efforts around the CherryPy project since 2004. The approach based on an example application introduces many other common Python libraries, providing transferable skills also relevant for non-web Python projects.


The book starts with two chapters dedicated to CherryPy, its history and installation. It then moves through a gentle introduction to the main features and concepts of CherryPy to a thorough review of its core capabilities. After laying this foundation the book dives into a real-world example, detailing important steps in the creation of a photoblog application. These chapters cover database manipulation via Object Relational Mapping (ORM), using web services to enhance the application, and client-side scripting through AJAX. Finally, the book covers the need for unit, functional, and performance testing before closing with deployment solutions for a CherryPy-based application.

Who this book is for

This book is principally geared towards Python web developers, who are looking to add the power of the CherryPy library to their existing Python skillset. It assumes a good working knowledge of Python. Although the CherryPy toolkit is at the core of the book, many other common libraries are introduced

Buy CherryPy Essentials: Rapid Python Web Application Development



Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software