CherryPy
Encyclopedia
CherryPy is an object-oriented web application framework
using the Python programming language
. It is designed for rapid development
of web application
s by wrapping the HTTP protocol
but stays at a low level and does not offer much more than what is defined in RFC
2616.
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, backend access, authentication
protocols. The framework is extensible with filters, simple interfaces
made of seven functions. These are called at defined points in the request/response processing.
For instance, the common Hello World program with CherryPy 3 would look like:
. You are free to use any kind of technology you want.
CherryPy wiki helps choosing a templating language.
Web application framework
A web application framework is a software framework that is designed to support the development of dynamic websites, web applications and web services. The framework aims to alleviate the overhead associated with common activities performed in Web development...
using the Python programming language
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...
. It is designed for rapid development
Rapid application development
Rapid application development is a software development methodology that uses minimal planning in favor of rapid prototyping. The "planning" of software developed using RAD is interleaved with writing the software itself...
of web application
Web application
A web application is an application that is accessed over a network such as the Internet or an intranet. The term may also mean a computer software application that is coded in a browser-supported language and reliant on a common web browser to render the application executable.Web applications are...
s by wrapping the HTTP protocol
Hypertext Transfer Protocol
The Hypertext Transfer Protocol is a networking protocol for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web....
but stays at a low level and does not offer much more than what is defined in RFC
Request for Comments
In computer network engineering, a Request for Comments is a memorandum published by the Internet Engineering Task Force describing methods, behaviors, research, or innovations applicable to the working of the Internet and Internet-connected systems.Through the Internet Society, engineers and...
2616.
CherryPy can be a web server itself or one can launch it via any WSGI compatible environment (including Apache
Apache HTTP Server
The Apache HTTP Server, commonly referred to as Apache , is web server software notable for playing a key role in the initial growth of the World Wide Web. In 2009 it became the first web server software to surpass the 100 million website milestone...
2). It does not deal with tasks such as templating for output rendering, backend access, authentication
Authentication
Authentication is the act of confirming the truth of an attribute of a datum or entity...
protocols. The framework is extensible with filters, simple interfaces
Interface (computer science)
In the field of computer science, an interface is a tool and concept that refers to a point of interaction between components, and is applicable at the level of both hardware and software...
made of seven functions. These are called at defined points in the request/response processing.
Pythonic interface
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:
Features http://www.cherrypy.org/#Features
- A fast, HTTP/1.1-compliant, WSGI threadThread (computer science)In computer science, a thread of execution is the smallest unit of processing that can be scheduled by an operating system. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process...
-pooled webserver. Typically, CherryPy itself takes only 1-2 ms per page. - Support for any other WSGI-enabled web serverWeb serverWeb server can refer to either the hardware or the software that helps to deliver content that can be accessed through the Internet....
or adapter, including ApacheApache HTTP ServerThe Apache HTTP Server, commonly referred to as Apache , is web server software notable for playing a key role in the initial growth of the World Wide Web. In 2009 it became the first web server software to surpass the 100 million website milestone...
, IISInternet Information ServicesInternet Information Services – formerly called Internet Information Server – is a web server application and set of feature extension modules created by Microsoft for use with Microsoft Windows. It is the most used web server after Apache HTTP Server. IIS 7.5 supports HTTP, HTTPS,...
, lighttpdLighttpdlighttpd is an open-source web server more optimized for speed-critical environments than common products while remaining standards-compliant, secure and flexible...
, mod pythonMod pythonmod_python is an Apache HTTP Server module that integrates the Python programming language into the Apache server. It is intended to replace Common Gateway Interface as a method of executing Python scripts on a web server. The promised benefits are faster execution speed and maintaining data over...
, FastCGIFastCGIFastCGI is a protocol for interfacing interactive programs with a web server. FastCGI is a variation on the earlier Common Gateway Interface ; FastCGI's main aim is to reduce the overhead associated with interfacing the web server and CGI programs, allowing a server to handle more web page...
, SCGI, and mod wsgiMod wsgimod_wsgi is an Apache HTTP Server module by Graham Dumpleton that provides a WSGI compliant interface for hosting Python 2.3+ based web applications under Apache. As of version 3.0, mod_wsgi supports Python 2.6 and 3.1...
. - A native mod pythonMod pythonmod_python is an Apache HTTP Server module that integrates the Python programming language into the Apache server. It is intended to replace Common Gateway Interface as a method of executing Python scripts on a web server. The promised benefits are faster execution speed and maintaining data over...
adapter. - Easy to run multiple HTTP servers (e.g. on multiple ports) at once .
- A flexible plugin system . 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 cachingCacheIn computer engineering, a cache is a component that transparently stores data so that future requests for that data can be served faster. The data that is stored within a cache might be values that have been computed earlier or duplicates of original values that are stored elsewhere...
, encodingCharacter encodingA character encoding system consists of a code that pairs each character from a given repertoire with something else, such as a sequence of natural numbers, octets or electrical pulses, in order to facilitate the transmission of data through telecommunication networks or storage of text in...
, sessionsSession (computer science)In computer science, in particular networking, a session is a semi-permanent interactive information interchange, also known as a dialogue, a conversation or a meeting, between two or more communicating devices, or between a computer and user . A session is set up or established at a certain point...
, authorizationAuthorizationAuthorization is the function of specifying access rights to resources, which is related to information security and computer security in general and to access control in particular. More formally, "to authorize" is to define access policy...
, static content, and many more. 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 very powerful syntax and configuration API for turning them on and off for a specific set of handlers. - A powerful configuration system for developers and deployers alike . 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 http://stackoverflow.com/questions/7170/recommendation-for-straight-forward-python-frameworks.
- A complete test suiteTest suiteIn software development, a test suite, less commonly known as a validation suite, is a collection of test cases that are intended to be used to test a software program to show that it has some specified set of behaviours. A test suite often contains detailed instructions or goals for each...
:- Lots of 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 , coverageCode coverageCode coverage is a measure used in software testing. It describes the degree to which the source code of a program has been tested. It is a form of testing that inspects the code directly and is therefore a form of white box testing....
and testing support.
Applications
Some open source connection
CherryPy doesn’t force you to use a specific object-relational mapper, template language or JavaScript libraryJavaScript library
A JavaScript library is a library of pre-written JavaScript which allows for easier development of JavaScript-based applications, especially for AJAX and other web-centric technologies....
. You are free to use any kind of technology you want.
Can be used with CherryPy
- Routes — a Python re-implementation of the Ruby on RailsRuby on RailsRuby on Rails, often shortened to Rails or RoR, is an open source web application framework for the Ruby programming language.-History:...
's routes system for mapping URLs to controllers/actions and generating URLs.
Object-relational mappers
- SQLAlchemySQLAlchemySQLAlchemy is an open source SQL toolkit and object-relational mapper for the Python programming language released under the MIT License.SQLAlchemy provides "a full suite of well known enterprise-level persistence patterns, designed for efficient and high-performing database access, adapted into a...
— a database backend and ORMObject-relational mappingObject-relational mapping in computer software is a programming technique for converting data between incompatible type systems in object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language...
for Python applications. TurboGearsTurboGearsTurboGears is a Python web application framework consisting of several WSGI components such as Pylons, SQLAlchemy, Genshi and Repoze.TurboGears is designed around the model-view-controller architecture, much like Struts or Ruby on Rails, designed to make rapid web application development in Python...
2.x uses CherryPy as server and SQLAlchemy as its default ORM . - SQLObjectSQLObjectSQLObject is a Python object-relational mapper between a SQL database and Python objects. It is currently experiencing community popularity, and forms a part of many applications...
— a popular ORMObject-relational mappingObject-relational mapping in computer software is a programming technique for converting data between incompatible type systems in object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language...
for providing an object interface to your database. Supports a number of common database backends: included in the distribution are MySQLMySQLMySQL officially, but also commonly "My Sequel") is a relational database management system that runs as a server providing multi-user access to a number of databases. It is named after developer Michael Widenius' daughter, My...
, PostgreSQLPostgreSQLPostgreSQL, often simply Postgres, is an object-relational database management system available for many platforms including Linux, FreeBSD, Solaris, MS Windows and Mac OS X. It is released under the PostgreSQL License, which is an MIT-style license, and is thus free and open source software...
, SQLiteSQLiteSQLite is an ACID-compliant embedded relational database management system contained in a relatively small C programming library. The source code for SQLite is in the public domain and implements most of the SQL standard...
, Sybase SQL Server, MaxDBMaxDBMaxDB is an ANSI SQL-92 compliant relational database management system from SAP AG, which was delivered also by MySQL AB from 2003 to 2007. MaxDB is targeted for large SAP environments e.g. mySAP Business Suite and other applications that require enterprise-level database functionality...
, Microsoft SQL ServerMicrosoft SQL ServerMicrosoft SQL Server is a relational database server, developed by Microsoft: It is a software product whose primary function is to store and retrieve data as requested by other software applications, be it those on the same computer or those running on another computer across a network...
and FirebirdFirebird (database server)Firebird is an open source SQL relational database management system that runs on Linux, Windows, and a variety of Unix. The database forked from Borland's open source edition of InterBase in 2000, but since Firebird 1.5 the code has been largely rewritten ....
. TurboGears 1.x uses CherryPy as server and SQLObject as ORM . - StormStorm (software)In computer software, Storm is a Python object-relational mapper between a SQL database and Python objects. It has been developed at Canonical Ltd...
— the ORMObject-relational mappingObject-relational mapping in computer software is a programming technique for converting data between incompatible type systems in object-oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language...
from Canonical Ltd.Canonical Ltd.Canonical Ltd. is a private company founded by South African entrepreneur Mark Shuttleworth to market commercial support and related services for Ubuntu Linux and related projects. Canonical is registered in London and employs staff around the world...
(makers of UbuntuUbuntu (operating system)Ubuntu is a computer operating system based on the Debian Linux distribution and distributed as free and open source software. It is named after the Southern African philosophy of Ubuntu...
). - Dejavu — a public domain, thread-safe ORM for Python applications.
Templating languages
- Mako — a template library written in Python, usable with a simple CherryPy tool .
- CheetahCheetahTemplateCheetah is a template engine that uses the Python programming language. It can be used standalone or combined with other tools and frameworks. It is often used for server-side scripting and dynamic web content by generating HTML, but can also be used to generate source code...
— an open source template engine and code generation tool, written in Python. - CherryTemplateCherryTemplateCherryTemplate is an open source templating language developed for CherryPy framework using the Python programming language. CherryTemplate is a simple yet relatively powerful templating language. It has a small instruction set...
— a templating language for CherryPy. - GenshiGenshi (templating language)Genshi is a template engine for XML-based vocabularies written inPython. Genshi is used to easily insert generated output into XML-based languages, usually HTML, and reuse elements between documents...
— a powerful XML templating language. - JinjaJinja (Template engine)Jinja is a template engine for the Python programming language. It is similar to the Django template engine but provides Python-like expressions while ensuring that the templates are evaluated in a sandbox. It's a text-based template language and thus can be used to generate any markup as well as...
— a general purpose templating language. CherryPy has a tool for using Jinja templates . - KidKid (Templating Language)Kid is a simple template engine for XML-based vocabularies written in Python. Kid claims to have many of the best features of XSLT, TAL, and PHP, but "with much of the limitations and complexity stamped out"....
— a simple template language for XML based vocabularies written in Python. TurboGearsTurboGearsTurboGears is a Python web application framework consisting of several WSGI components such as Pylons, SQLAlchemy, Genshi and Repoze.TurboGears is designed around the model-view-controller architecture, much like Struts or Ruby on Rails, designed to make rapid web application development in Python...
1.x uses CherryPy as server and Kid as frontend .
CherryPy wiki helps choosing a templating language.
JavaScript libraries
- Sarissahttp://sourceforge.net/projects/sarissa/files/ — a cross-browser library for AjaxAjax (programming)Ajax is a group of interrelated web development methods used on the client-side to create asynchronous web applications...
. - jQueryJQueryjQuery is a cross-browser JavaScript library designed to simplify the client-side scripting of HTML. It was released in January 2006 at BarCamp NYC by John Resig...
— a lightweight library that emphasizes interaction between JavaScript and HTML. - PyjamasPyjamas (software)Pyjamas is a tool and framework for developing Ajax applications in Python. It contains a stand-alone Python-to-JavaScript compiler, an Ajax framework and widget toolkit, and through use of these components, developers can write comprehensive applications, to run in all major web browsers, without...
— a Python to JavaScript compiler and a web widget set.
Further reading
- CherryPy Essentials: Rapid Python Web Application Development, First Edition (March 2007), ISBN 978-1-904811-84-8