ArticleslgStudy

computer science

TurboGears

TurboGears 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 TurboGears rather than just read about it. In short: TurboGears is a Python web application framework consisting of several WSGI components such as WebOb, SQLAlchemy, Kajiki template language and Repoze. TurboGears is designed around the model–view–controller (MVC) architecture, much like Struts or Ruby on Rails, designed to make rapid web application development in Python easier and more maintainable.

TurboGears — main illustration
TurboGears — illustration

Key takeaways

  • TurboGears 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 TurboGears to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of TurboGears from memory before moving on to harder problems.

Reference excerpt

TurboGears is a Python web application framework consisting of several WSGI components such as WebOb, SQLAlchemy, Kajiki template language and Repoze. TurboGears is designed around the model–view–controller (MVC) architecture, much like Struts or Ruby on Rails, designed to make rapid web application development in Python easier and more maintainable. Since version 2.3 the framework has also been providing a "minimal mode" which enables it to act as a microframework for usage in environments where the whole stack is not required nor wanted.

TurboGears components TurboGears is built on top of numerous disparate libraries and middleware. The default tools have changed between the 1.x, 2.x and 2.3+ series, but most of these components can be used in either as there is support for many alternative configurations. The following are the primary components a developer would interact with.

TurboGears 2.x components SQLAlchemy (Model) - defines the table structures of the user's database and how to link them to Python objects the user's controller can interact with. Ming (Model) - provides the data access layer for MongoDB, much like SQLAlchemy defines how to link MongoDB collections to Python objects the user's controller can interact with. Kajiki (previously Genshi) (View) - defines templates for the HTML or XHTML the user will generate. This is where the user defines the front-end the client will interact with. Repoze - Repoze.who is used to handle security (identification and authentication). Users can define authorization rules based on predicates attached to controllers, the framework already provides some built-in predicates, but custom ones can be written. ToscaWidgets - is the primary widget library for creating forms and complex GUIs. Tosca by default will generate simple HTML forms, but can also be used as a middleware to connect to more advanced JavaScript widgets and toolkits. Unlike TurboGears 1.x, there is no longer a preferred/integrated JavaScript library. Gearbox - is the toolkit used by TurboGears to manage projects, create new ones and serve TurboGears applications but the user can also connect to Apache, Nginx, or any other WSGI-compatible web server. Versions before 2.3 would also use:

Pylons (Controller) - this middleware handles all the user's back-end logic and connects to the user's web server to offer up data to the web. Paster was the command toolkit and web server used in place of Gearbox. Repoze.what - Used to handle authorization respectively. When defining elements of the user's controller to be exposed to the web, repoze.what predicates define who can access them and under what conditions.

TurboGears 1.x components SQLObject (Model) - data backend that can create a database or interface with existing data on many database servers. SQLAlchemy is slated to become the default in TurboGears >= 1.1. Kid (View) - XHTML frontend templating engine where all templates are valid XHTML or XML files that are usually made in a way that allows opening these templates as simple XHTML files to check the design. At the same time features are provided to embed snippets of Python in a XMLish manner. Genshi is the successor to Kid and will replace it as the default templating engine in TurboGears >= 1.1. It is nearly 100% syntax-compatible to Kid. CherryPy (Controller) - middleware that allows web applications to be programmed by writing event handlers that return data to (in TurboGears case) templates. The same data can also be received in Ajax fashion as a JSON data stream. MochiKit is the preferred, but optional JavaScript library for TurboGears 1.x. It is a designed to make programming in JavaScript more pythonic. It is mostly used for implementing Ajax features and widgets as it provides an interface to get JSON data streams in asynchronous manner.

Template plugins Templating languages other than Genshi can be used through the user's app's configuration file. Plugins currently supported in 2.1 are Myghty, Jinja2, Mako, Cheetah, and Kajiki. Kid support is not currently planned as Genshi is virtually identical. This list may continue to change in future versions.

… excerpt ends here. Continue reading the full article.

Illustrations

TurboGears illustration

Worked examples

Example 1 — a first encounter with TurboGears

Start with the simplest possible case. Write down what TurboGears 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 TurboGears 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 TurboGears 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 TurboGears

In research
TurboGears 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 TurboGears 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
TurboGears is common in secondary-school and first-year university syllabi. It links to neighbouring topics Python (programming language) web frameworks, Software programmed in Python, Software using the MIT license, so understanding it makes those chapters shorter.
In everyday life
Look for TurboGears 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 “TurboGears” →

How to study TurboGears in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what TurboGears 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 TurboGears out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is TurboGears in simple terms?

TurboGears is a Python web application framework consisting of several WSGI components such as WebOb, SQLAlchemy, Kajiki template language and Repoze. TurboGears is designed around the model–view–controller (MVC) architecture, much like Struts or Ruby on Rails, designed to make rapid web applicatio…

Why does TurboGears 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 TurboGears?

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 TurboGears.

Tags

  • Python (programming language) web frameworks
  • Software programmed in Python
  • Software using the MIT license

Keep exploring