Section 2.1. Installing TurboGears and SQLite


2.1. Installing TurboGears and SQLite

Before you can start writing cool new TurboGears applications, you have to install it and all of its component pieces on your computer. The good news is that thanks to Phillip Eby, Python Eggs, and Easy Install, this is now amazingly easy to do for anybody running Windows, Linux, or Mac OS X.

With Philip Eby's Easy Install package, installing TurboGears is now as easy as this:

  1. Install Python 2.4 or 2.5, if not already installed. You certainly can use TurboGears with 2.3, but unless you have a compelling reason to do that, your experience is going to be significantly better if you use a newer Python release. If you do choose to use Python 2.3, you must do some things differently than we do here in this book because TurboGears makes heavy use of function/method decorators to save you time and to make your code easier to read. So, although you can use TurboGears with 2.3, the examples in this book are specifically designed to work with Python 2.4 or later. See the sidebar "Decorators in Python 2.3" for more information.

  2. Install TurboGears by downloading the setuptools/EasyInstall bootstrap script (ez_setup) and running it. You can find the script, along with detailed platform-specific instructions, at www.turbogears.org/download.

  3. Install and configure whatever database back end you need.

The easiest way to get a SQL database is to install SQLite 3 and pysqlite 2. On Windows, this is as easy as easy-install pysqlite. If you use Ubuntu or another Debian-based Linux version, you can apt-get install SQLite, and then apt-get install pysqlite2. Red Hat and SUSE have RPM Packet Managers (RPMs) in their repository.

What Are Python Eggs?

In addition to a robust standard library, Python has a huge selection of freely available and usable add-on libraries. These libraries do everything from providing cross-platform graphical user interfaces to complex mathematics. The Python Cheeseshop, formerly the Python Package Index (PyPI), provides an index to many of these packages.

Before the Eggs, installing one of these packages meant doing this: following the links from the Cheeseshop until you can download it, downloading the package, and running python setup.py install.

On some Linux systems, you can apt-get <somepackage> and have the package installed. On the Mac, you can get something similar from Fink or DarwinPorts. Things get more complicated when you bring Windows into the picture.

To make matters worse, some packages depend on other packages to function. Sometimes it's harder than it should be to install an applicaiton and all its dependencies.

This is where Python "eggs" come in. Phillip Eby's setuptools package enables your Python to handle eggs, and the convenient easy_install command makes installing Python packages consistent and easy on every platform.

Thanks to setuptools, you can type easy_install TurboGears to get TurboGears and the correct versions of many packages that TurboGears uses, all in the correct formats for your platform.

The egg format provides a plug-in extension mechanism that packages such as TurboGears can use. For example, TurboGears supports plug-in packages of widgets. After you install an egg containing widgets, those widgets automatically appear in tools such as the TurboGears Widget Browser.

Unlike traditional Python packages, eggs also have the advantage of allowing you to install multiple versions of a package and choose the correct one at runtime. This multiple install enables you to test out code with both development and stable versions of a library to ensure that your application runs well with both versions.


You can find more detailed install instructions at www.turbogears.org. The TurboGears site always contains the most up-to-date platform-specific instructions. It also has instructions on how to do a rootless install on Linux and some tricks to help make your install experience on Windows as easy as possible.

If you already have MySQL or postgres 8 installed, however, you can just use that.

Note

We assume your familiarity with using the command line on your platform of choice. Some Windows and Mac OS X users seem not to have discovered the power of the command line. If you're one of those people, take a few minutes and make friends with the command line. I promise she's a great friend to have and can definitely bail you out of a lot of trouble. You can find lots of links to more information about using the command line at www.turbogearsbook.com/command-line.





Rapid Web Applications with TurboGears(c) Using Python to Create Ajax-Powered Sites
Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites
ISBN: 0132433885
EAN: 2147483647
Year: 2006
Pages: 202

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net