CherryPy

From Wikipedia, the free encyclopedia
Jump to: navigation, search
CherryPy
Developer(s) CherryPy team
Stable release 3.6.0[1] / September 14, 2014 (2014-09-14)
Written in Python
Operating system Cross-platform
Type Web application framework
License BSD License
Website www.cherrypy.org

CherryPy is an object-oriented web application framework using the Python programming language. It is designed for rapid development of web applications by wrapping the HTTP protocol but stays at a low level and does not offer much more than what is defined in RFC 7321.

CherryPy can be a web server itself or one can launch it via any WSGI compatible environment (including Apache 2). It does not deal with tasks such as templating for output rendering or backend access. The framework is extensible with filters, simple interfaces made of seven functions. These are called at defined points in the request/response processing.

Pythonic interface[edit]

One of the goals of the project founder, Remi Delon, was to make CherryPy as pythonic as possible. This allows the developer to use the framework as any regular Python module and to forget (from a technical point of view) that the application is for the web.

For instance, the common Hello World program with CherryPy 3 would look like:

import cherrypy
 
class HelloWorld(object):
    def index(self):
        return "Hello World!"
    index.exposed = True
 
cherrypy.quickstart(HelloWorld())

Features[edit]

CherryPy implements:

  • a HTTP/1.1-compliant, WSGI thread-pooled webserver.[2] Typically, CherryPy itself takes [3][4] only 1-2 ms per page.
  • Support for any other WSGI-enabled web server or adapter, including Apache, IIS, lighttpd, mod_python, FastCGI, SCGI, and mod_wsgi.
  • A native mod_python adapter.
  • multiple HTTP servers (e.g. on multiple ports) at once.[5]
  • A plugin system[6] CherryPy plugins hook into events within the server process — into server startup, server shutdown, server exiting, etc. — to run code that needs to be run when the server starts up or shuts down.
  • Built-in tools for caching, encoding, sessions, authorization, static content, and others. CherryPy tools hook into events within the request process. Whenever the CherryPy server receives a request, there is a specific set of steps it goes through to handle that request. Page handlers are only one step in the process. Tools also provide a syntax and configuration API for turning them on and off for a specific set of handlers.
  • A configuration system for developers and deployers .[7][8][9] CherryPy deployments are configurable on site, on application and on controller level, through Python dictionaries, configuration files, and open file objects.
  • Swappable and customizable every component [1].
  • a complete test suite:[10]
    • tests for both basic and advanced functionality
    • command-line options to control which tests are run, and the output they produce
    • debugging tools specifically for web page tests
    • many of the test suite components are reusable by applications.
  • built-in profiling since v2.1,[11] coverage [12] and testing support.

CherryPy doesn’t force you to use a specific object-relational mapper, template language or JavaScript library.

Can be used with CherryPy[edit]

  • Routes [13] — a Python re-implementation of the Ruby on Rails's routes system for mapping URLs to controllers/actions and generating URLs.

Object-relational mappers[edit]

Templating languages[edit]

  • Mako[17] — a template library written in Python, usable with a simple CherryPy tool.[18]
  • Cheetah — an open source template engine and code generation tool, written in Python.
  • CherryTemplate — a templating language for CherryPy.
  • Genshi [19][20] — a powerful XML templating language.
  • Jinja — a general purpose templating language. CherryPy has a tool for using Jinja templates.[21]
  • Kid — a simple template language for XML based vocabularies written in Python. TurboGears 1.x uses CherryPy as server and Kid as frontend.[22]

CherryPy wiki helps [23] choosing a templating language.

JavaScript libraries[edit]

  • Sarissa[24] — a cross-browser library for Ajax
  • jQuery — a lightweight library that emphasizes interaction between JavaScript and HTML
  • Pyjamas — a Python to JavaScript compiler and a web widget set

CherryPy is a component of[edit]

  • TurboGears — CherryPy 2.x is a main component of TurboGears 1.x.

References[edit]

External links[edit]