Monday, August 13, 2007

Learn from WhatWhat Status application

If you're new to Turbogears, this is great overview about it. WhatWhat Status is a simple approach to project status tracking. We hope that it can be employed and improved by others, and can be a good learning tool for TurboGears programmers.

  1. download now
  2. unzip the file (pwd : deiruse)
  3. copy and paste at C:\Python25\Scripts
  4. run your mysql program.
  5. In the folder whatwhat
    • select file dev.cfg (change [sqlobject.dburi="postgres://postgres@localhost:5432/whatwhat?cache="] to [sqlobject.dburi="mysql://root:@localhost:3306/whatwhat"] )
    • select file initialize-mysql.sql import it using phpmyadmin
  6. to start your whatwhat status, open your command prompt
  7. press enter.
  8. Open your browser, http://localhost:8080
  9. username and password : admin, have fun !

MySQL Database with Turbogears

MySQL Installation


You will need the MySQL databases.
  1. Grab the at Installer or Mysql_Installer
  2. Run the installer.
You will need the MySQLdb python module.
  1. Grab the at Installer.
  2. Run the installer.

Turbogears Installation

Getting Python

If you're new to Python, welcome. It's a great language

  1. Grab the Python 2.5 Installer.
  2. Run the installer.
  3. Add Python to your path.

    To do this, go to System Properties -> Advanced -> Environment Variables and add or edit the PATH variable to have ;C:\Python25;C:\Python25\Scripts, assuming you installed Python to the default location.


Installing TurboGears

You can run Python from any shell if your Python scripts directory is on your path. By default the scripts directory is C:Python25Scripts

  1. Open up a command line prompt (Start -> Run and type cmd)
  2. Download tgsetup.py and run
python tgsetup.py
  1. Make sure your installation succeeded by running tg-admin info.
edit from: http://docs.turbogears.org/1.0/InstallWindows

The Big Picture


This diagram does not as bad as it may seem. It shows core parts that make up a TurboGears application.

TurboGears followed MVC (Model, View, Controller) design pattern, which seperate the web application design into three different roles, to build the default quickstart project.

A great deal of it comes from TurboGears itself. Your application consists of the parts in the light purple boxes. Let's look at each part:

Model

  • Your model objects represent the data that your application is working with.

Controller

  • The controller's responsibility is to map URLs to actual functionalities.
  • Those functionalities are able to call the model's API to retrieve and/or update the data in the database or other object.
  • Controller is able to choose some sort of templating engine to provide the user's view of the data.

View

  • In TurboGears, your view is in templates that present the information that is provided by the controller.

The controller is the basis of the framework, and that the view and the model can be created in other ways. It means TurboGears also offer you the flexibility to 'not use the MVC' as well.

Thus you can port existing web software into TG without an immediate complete revision to all of the code.

You have these three areas to populate with code in order to make your application. TurboGears provides help at each point.

  • CherryPy makes it easy for your controller to get information from the web and string together all of the pieces that comprise your website.
  • SQLObject makes it easy to define and work with your model.
  • Kid makes it easy to generate good HTML for the browser.
  • MochiKit makes it easy to implement complex in-the-browser behavior and can even be used to format output in AJAX requests that skip over Kid.
source from: http://docs.turbogears.org/1.0/GettingStarted/BigPicture

What's turbogears?

TurboGears is a rapid development "front-to-back" web meta-framework. Its aim is to simplify and speed up the development of modern web applications written in the Python programming language.

Create great web apps faster!

That's it. That's the goal of TurboGears … That and to make it easier: The two goals are to create web apps faster and easier … And more fun: The three goals are to …

How does TurboGears do it?

  • By making it as easy as writing a method to expose functionality to the web
  • By allowing you to seamlessly provide nice HTML or an API for JavaScript to work with
  • By giving your designers room to work with any XHTML tool to create great layouts
  • By letting you use your database without writing SQL
  • By filling in gaps in JavaScript, so that you'll actually enjoy writing it!
  • By using a language that is clear, concise and dynamic

More than the sum of its parts!

TurboGears takes the best components available and combines them into one easy-to-install, documented whole. TurboGears includes parts that join the pieces together and make them work together seamlessly, but doesn't obscure each included project. This allows you to take advantage of all existing documentation, articles, mailing lists and other resources that have built up in the communities for each project.

From frontend to backend:

  • MochiKit is a clean and powerful JavaScript library
  • Kid is a designer- and programmer-friendly template system
  • CherryPy makes doing web input/output as easy as writing a Python function!
  • SQLObject lets you access your database as you would normal Python classes, without obscuring the database itself.

Now that you know a bit about the parts of TurboGears, read more about how TurboGears ties it all together.

But, wait! There's more!

If TurboGears were a movie and the four projects above were the main actors, we'd still need key grips, caterers and the like. Here are some of the other bits of infrastructure needed for TurboGears:

  • ElementTree is an easy-to-use and blazingly fast XML library.
  • FormEncode provides a simple and extensible validation framework.
  • Nose extends standard Python unittest features to make running your tests easier.
  • json-py does round trip conversions between Python and the JSON format.

Python and every other language out there have many choices available for each part of a web application. First and foremost, TurboGears assembles a great collection of tools, packages them for use together and provides information on best practices when used together. Many people have similar needs when developing web applications, and there's a lot to be gained by putting it all together.

source from: http://turbogears.org/about/