CherryPy

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

Template:Short description Script error: No such module "Infobox".Template:Template otherScript error: No such module "Check for unknown parameters".Template:Main other Script error: No such module "Unsubst". 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 7231.

CherryPy can be a web server itself or one can launch it via any WSGI compatible environment. It does not deal with tasks such as templating for output rendering or backend access. The framework is extensible with filters, which 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:

import cherrypy

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

cherrypy.quickstart(HelloWorld())

Features

CherryPy implements:

  • A HTTP/1.1-compliant, WSGI thread-pooled webserver.[1] Typically, CherryPy itself takes only 1–2 ms per page.[2][3]
  • 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. ability to listen on multiple ports).[4]
  • A plugin system[5] 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 .[6][7][8] CherryPy deployments are configurable on site, on application and on controller level, through Python dictionaries, configuration files, and open file objects.
  • A complete test suite for core functionality and associated framework which can be used to test CherryPy applications.[9]
  • Built-in profiling since v2.1,[10] coverage[11] and testing support.

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

Can be used with CherryPy

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

Object-relational mappers

Templating languages

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

CherryPy wiki helps[22] choosing a templating language.

Products using CherryPy

  • TurboGears — CherryPy 2.x is a main component of TurboGears 1.x.
  • Splunk Enterprise - CherryPy 3.1.2[23]

See also

Script error: No such module "Portal".

References

Template:Reflist

External links

Template:Python web frameworks Template:Web frameworks

  1. Script error: No such module "citation/CS1".
  2. Script error: No such module "citation/CS1".
  3. How fast is CherryPy? Template:Webarchive
  4. Script error: No such module "citation/CS1".
  5. Custom engine plugins with CherryPy Template:Webarchive
  6. Configuration system of CherryPy Template:Webarchive
  7. Configuration API of CherryPy Template:Webarchive
  8. Short summary of configuration options
  9. How to test CherryPy itself Template:Webarchive
  10. Profiler module of CherryPy Template:Webarchive
  11. Script error: No such module "citation/CS1".
  12. Script error: No such module "citation/CS1".
  13. TurboGears 2.x uses CherryPy as server and SQLAlchemy as its default ORM
  14. TurboGears 1.x uses CherryPy as server and SQLObject as ORM Template:Webarchive
  15. Dejavu Template:Webarchive
  16. Mako
  17. Script error: No such module "citation/CS1".
  18. Script error: No such module "citation/CS1".
  19. Script error: No such module "citation/CS1".
  20. Script error: No such module "citation/CS1".
  21. TurboGears 1.x uses CherryPy as server and Kid as frontend Template:Webarchive
  22. CherryPy wiki about choosing a templating language Template:Webarchive
  23. Script error: No such module "citation/CS1".