ArticleslgStudy

computer science

CherryPy

CherryPy is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand CherryPy rather than just read about it. In short: 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.

Key takeaways

  • CherryPy belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect CherryPy to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of CherryPy from memory before moving on to harder problems.

Reference excerpt

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:

Or, as the example currently shows on their website, using Python decorators to automatically expose the index route:

Features CherryPy implements:

A HTTP/1.1-compliant, WSGI thread-pooled webserver. Typically, CherryPy itself takes 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. ability to listen on multiple ports). A 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 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 . 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. Built-in profiling since v2.1, coverage 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.

Object–relational mappers SQLAlchemy — a database backend and ORM for Python applications. TurboGears 2.x uses CherryPy as server and SQLAlchemy as its default ORM. SQLObject — a popular ORM for providing an object interface to a database. Supports a number of common database backends: included in the distribution are MySQL, PostgreSQL, SQLite, Sybase SQL Server, MaxDB, Microsoft SQL Server and Firebird. TurboGears 1.x uses CherryPy as server and SQLObject as ORM. Storm — the ORM from Canonical Ltd. (makers of Ubuntu) Dejavu — a public domain software, thread-safe ORM for Python applications MongoEngine — An ODM for connecting to MongoDB.

Templating languages Mako — a template library written in Python, usable with a simple CherryPy tool. Cheetah — an open source template engine and code generation tool, written in Python. CherryTemplate — a templating language for CherryPy. Genshi — a powerful XML templating language. Jinja — a general purpose templating language. CherryPy has a tool for using Jinja templates. Kid — a simple template language for XML based vocabularies written in Python. TurboGears 1.x uses CherryPy as server and Kid as frontend. CherryPy wiki helps 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

See also

Comparison of web frameworks

References

External links Official website

Worked examples

Example 1 — a first encounter with CherryPy

Start with the simplest possible case. Write down what CherryPy claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to CherryPy before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about CherryPy ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of CherryPy

In research
CherryPy appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses CherryPy in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
CherryPy is common in secondary-school and first-year university syllabi. It links to neighbouring topics Free computer libraries, Free software programmed in Python, Python (programming language) web frameworks, so understanding it makes those chapters shorter.
In everyday life
Look for CherryPy outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “CherryPy” →

How to study CherryPy in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what CherryPy means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain CherryPy out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is CherryPy in simple terms?

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.

Why does CherryPy matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study CherryPy?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on CherryPy.

Tags

  • Free computer libraries
  • Free software programmed in Python
  • Python (programming language) web frameworks
  • Software using the BSD license

Keep exploring