text: Contents
  The nerve center of Turbo Gears is the controller. All HTTP requests arrive tg-admin quickstart you generate a TurboGears project named “gs”. Your default controller code would be created in the file gs/gs/controllers.py.
  Modify the default controllers.py to read as follows:
  from turbogears import controllers, expose class Root(controllers.RootController): @expose() def index(self): return "<h1>Hello World</h1>" @expose() def default(self, *args, **kw): return "This page is not ready"
  It is important that you indent the lines in the same way as above.
  When you load the root URL in your web browser, you’ll see a page with the message “Hello World” on it. In addition, any of these URLs will return the same result.
  URLs not explicitly mapped to other methods of the controller will be directed to the method named default(). With the above example, requesting any URL besides /index, for example, will return the message “This page is not ready”.
  When you are ready to add another page to your site, for example at the URL
  add another method to class Root as follows:
  @expose() def anotherpage(self): return "<h1>There are more pages in my website</h1>"
  Now, the URL /anotherpage will return
  There are more pages in my website
  from turbogears import controllers, expose
  First you need to import the required modules from the TurboGears package.
  Controller classes and the expose decorator are the basis of TurboGears controllers.:
  class Root(controllers.RootController):
  The required standard name for the root controller class of a TurboGears application is Root and it should be inherited from RootController class (from the controllers module, which we just imported). It is thereby specified as the request handler class for the website’s root.
  In TurboGears (and CherryPy, on which TurboGears 1.x builds), the web site is represented by a tree of controller objects and their methods, and a TurboGears website always grows out from the Root class.
  We look at the methods of the Root class next:
  def index(self): return "<h1>Hello World</h1>"
  The index method is the start point of any TurboGears/CherryPy class. When you access a URL like
  they are all mapped to the Root.index() method.
  If a URL is requested.
  Note
  Because Python 2.3 doesn’t support decorator syntax, you have to use [@expose()] instead of @expose() with Python 2.3. For more details on the @expose decorator, see the expose decorator page.
  A simple template file called sample could be made like this:
  <html> <head> <title>TurboGears Templating Example</title> </head> <body> <h2>I just want to say that ${person} should be the next ${office} of the United States.</h2> </body> </html>
  By adding a method to the controller like this ...
  @expose(template="gs.templates.sample") def example(self): mydata = {'person':'Tony Blair','office':'President'} return mydata
  ... the following is made possible:
  I just want to say that Tony Blair should be the next President of the United States.
  Template files can thus house all markup information, maintaining clean separation from controller code.
  In TurboGears, template files are collected together in the templates sub-package, i.e. in the folder named templates below your application’s main package directory, in this case, ./gs/gs/templates and referred to in @expose by the syntax [packagename].templates.[filenameroot], as in the example.
  In the above Example Use of Templates, our template used the mydata values simply as direct content replacement strings. Templates are much more capable than this. They can run their own Python code snippets to aid in rendering, such as obeying conditionals or iterating through lists. To learn more, read Getting Started with Kid.
  In typical Pythonic elegance, arguments can be passed to the controller methods from the web browser. To learn how, read I wanted an argument.
  The example above shows your controller methods all contained within the single Root class. Your controller can grow into multiple sub-classes, and from there into multiple modules and files. See Creating Big Applications.