SlideShare a Scribd company logo
1 of 41
Download to read offline
Introduction to TurboGears


           Mike Pirnat
   Clepy Meeting: 11/07/2005
   http://www.pirnat.com/geek/
What, Another Python Framework??
“You're not a Real Python Programmer until you've
 written your own web templating toolkit.”
  -- Moshe Zadka


“Stop writing kewl new frameworks! Help improve
  the top few frameworks so they can become a
  best of breed.”
  -- Michelle Levesque
What is TurboGears?
●   Python “megaframework” for web apps
●   Pythonic answer to Ruby on Rails
●   Rapid web development
●   Rapidly growing community—over 500 users on
    the mailing list since late September!
●   Not afraid of “Not Invented Here”
●   Under heavy development
●   Shiny and new... or is it?
TurboGears Philosophy
●   Create great web apps faster, easier, and more fun
●   Use the best available existing components
●   Combine in an easy-to-use package
●   Deliver an excellent out-of-box experience
●   MVC == good
●   Eliminate tedium with abstraction, tools
●   TurboGears provides the “glue” so that you don't
    have to make your own
TurboGears Components
●   Database ORM access: SQLObject
●   Application server: CherryPy
●   Template engine: Kid
●   Javascript/AJAX library: MochiKit
●   Automated testing: TestGears, Nose
TurboGears Kickstarts Your App
●   Create a new project and directory structure with
     tg­admin quickstart
●   Start your server with python PROJECT­start.py
    (created by quickstart in the root of your app)
●   Your install is now up and running at: http://localhost:8080/!
●   Set up your dev.cfg (created automatically) with database
    connection string
●   Define your data model using SQLObject subclasses, then
    run tg­admin sql create
●   Then the fun part begins!
SQLObject
●   Object Relational Manager
●   Database tables are classes, rows are instances,
    fields are attributes
●   Eliminates need to write SQL by hand (mostly)
●   Use with MySQL, PostgreSQL, sqlite, Firebird
●   Sybase and Oracle support in progress
●   Can generate DB from Python, or Python from
    DB!
SQLObject
●   Supports joins, one-to-many, and many-to-many
    relationships
●   Supports transactions
●   Can do lazy updates to minimize DB chatter
●   Result sets are lazily evaluated generators
●   Result sets can be sliced => different SQL
●   Caches objects retrieved from DB
●   Can still do full-on SQL if needed
●   http://sqlobject.org/
SQLObject: Example
from sqlobject import *
from datetime import datetime

class Person(SQLObject):
    firstName = StringCol(length=100)
    middleInitial = StringCol(length=1, default=None)
    lastName = StringCol(length=100)
    lastContact = DateTimeCol(default=datetime.now)

# create a new record
p = Person(firstName=”John”, lastName=”Doe”)

# get an existing record
p1 = Person.get(1)

# select multiple records
peeps = Person.select(Person.q.firstName==”John”)
CherryPy
●   Pythonic, objected-oriented web app framework
●   Maps URL request to a Python method using
    decorators
●   CGI variables are mapped to method arguments
●   Does not support SSL natively; put it behind
    Apache with mod_proxy or mod_python to allow
    secure traffic
●   http://www.cherrypy.org
CherryPy: Example
import cherrypy

class MyRoot:

    @cherrypy.expose()
    def index(self, who=”World”):
        return “Hello, %s!” % who
CherryPy/TurboGears: Examples
import cherrypy                     import turbogears
                                    from turbogears import controllers
class MyRoot:
                                    class MyRoot(controllers.Root):
    @cherrypy.expose()
    def index(self, who=”World”):       @turbogears.expose(html=”foo”)
        return “Hello, %s!” % who       def index(self, who=”World”):
                                            return dict(who=who)
Kid
●   Templates are well-formed XML
●   Attribute language similar to Zope's TAL
●   Compiled to Python byte-code
●   Processed using a pull-style parser based on
    ElementTree
●   Supports template inheritance and XSLT-like matching
●   Designer-friendly: viewable in browser
●   http://kid.lesscode.org
Kid: Example
<?python                                      <?xml version=quot;1.0quot; encoding=quot;utf­8quot;?>
title = quot;A Kid Test Documentquot;                 <html>
fruits = [quot;applequot;, quot;orangequot;, quot;kiwiquot;, quot;M&Mquot;]     <head>
from platform import system                       <title>A Kid Test Document</title>
?>                                              </head>
<html xmlns:py=quot;http://purl.org/kid/ns#quot;>       <body>
  <head>                                          <p>These are some of my favorite 
    <title py:content=quot;titlequot;>This is         fruits:</p>
replaced.</title>                                 <ul>
  </head>                                           <li>I like apples</li>
  <body>                                            <li>I like oranges</li>
    <p>These are some of my favorite                <li>I like kiwis</li>
fruits:</p>                                         <li>I like M&amp;Ms</li>
    <ul>                                          </ul>
      <li py:for=quot;fruit in fruitsquot;>               <p>
        I like ${fruit}s                            Good for you!
      </li>                                       </p>
    </ul>                                       </body>
    <p py:if=quot;system() == 'Linux'quot;>           </html>
      Good for you!
    </p>
  </body>
</html>
Kid: Template Inheritance
●   Master template defines a “template function”
    <div py:def=”header(title)”>
      <h1>${title}</h1>
    </div>

●   Individual templates extend the master and call
    the function:
    <html py:extends=”'common.kid'”> ...
    <div py:replace=”header('Foo!')”>This will be 
      replaced</div>
    ...
    </html>
Kid: Matching
●   Individual templates extend from master
●   Master template defines a matching rule:
<body py:match=”item.tag=='{http://www.w3.org/1999/xhtml}
body'”>
  <h1>${title}</h1>
  <div py:replace=”item[:]”>
MochiKit
●   Pythonic JavaScript library
●   “Makes JavaScript suck less”
●   Well-documented
●   Reliable (lots of automated tests)
●   Single JS import to have access to all features
●   Features galore...
●   http://mochikit.com
MochiKit: Features
●   Asynchronous tasks   ●   Iteration (ala Python's
●   DOM manipulation         itertools)
●   Color abstraction
                         ●   Logging
●   Date and time
                         ●   Interactive JavaScript
                             shell
●   String formatting    ●   Visual effects
MochiKit: Sorting & Accessing
myObjectArray = [
  {“a”: 3, “b”: 2},
  {“a”: 1, “b”: 2}
];

// sort by the “a” property
myObjectArray.sort(keyComparator(“a”));

// get just the “a” values out into an array
sortedAValues = map(itemgetter(“a”), myObjectArray);
MochiKit: DOM Manipulation
var rows = [
  [“dataA1”, “dataA2”, “dataA3”],
  [“dataB1”, “dataB2”, “dataB3”]
];

row_display = function(row) {
  return TR(null, map(partial(TD, null), row));
}

var newTable = TABLE({'class': 'prettytable'},
  THEAD(null, row_display([“head1”, “head2”, “head3”])),
  TFOOT(null, row_display([“foot1”, “foot2”, “foot3”])),
  TBODY(null, map(row_display, rows)));

swapDOM(oldTable, newTable);
Testing: TestGears and Nose
●   TurboGears up to 0.8: TestGears
●   TurboGears 0.9+ will use Nose
●   Both are unittest extensions that mimic the
    behavior and ease-of-use of py.test
●   Automated test discovery and execution
●   More info:
    –   http://www.turbogears.org/testgears
    –   http://somethingaboutorange.com/mrl/projects/nose
TestGears
●   Where to put tests? Generally in a “tests”
    package in your project
●   Running tests? At the top level directory of your
    project, run: python setup.py testgears
●   Testing methods:
    – Directly
    – Simulating a web request
TestGears: Direct Testing
from turbogears.tests import util
from myproject.controllers import Root
import cherrypy

def test_indextitle():
    “””Index method should return a title.”””
    cherrypy.root = Root()
    output = util.call(cherrypy.root.index)
    assert output['title'] == 'foobar'
    assert output.has_key('now')
TestGears: Simulating a Web Request
from turbogears import util
from myproject.controllers import Root
import cherrypy

def test_indextitle_in_template():
    “””Index template should have a title.”””
    cherrypy.root = Root()
    util.createRequest('/')
    assert “<title>Foobar</title>” in 
            cherrypy.response.body[0]
The Infamous 20-Minute Wiki
●   How do we put components together?
●   How quickly can we make an app?
●   Would you believe... a usable wiki in 20 minutes?
●   “Screencast” inspired by the Ruby on Rails
    introductory video
    –   http://www.turbogears.org/docs/wiki20/20MinuteWiki.mov
    –   http://www.turbogears.org/docs/wiki20/index.html
Current “Hot Topics”
●   CRUD
●   Identity
●   Installation, Upgrading, Deployment
●   Kid issues
●   SQLObject issues
●   Forms: Validation & Generation
Hot Topics: CRUD
●   CRUD = Create, Retrieve, Update, Delete
●   TG wanted to include “free CRUD” ala Django and Rails
●   Several groups started in their own directions
●   When suddenly... along came CatWalk!
     –   Manage and interact with your TG models from a browser
     –   http://checkandshare.com/catwalk/
     –   Now included with TurboGears SVN
     –   Will be bundled in 0.9+
Hot Topics: Identity
●   Jeff Watkins is producing an identity framework for
    TurboGears
●   Should be ready for TG 0.9
●   User, group, permission scheme
●   IP-based access control
●   Should be interchangeable with other preferred/required
    identity models which implement a consistent interface
●   http://newburyportion.com/nerd/2005/10/identity-management-for-turbogears
Hot Topics: Installation & Upgrading
●   Initial installation is easy thanks to Easy Install:
     sudo python ez_setup.py ­f http://www.turbogears.org/download/index.html 
         ­­script­dir /usr/local/bin TurboGears

●   TG and friends are distributed as Python Eggs
●   Upgrading has been tricky, often requiring updates to the
    update framework in order to get the latest versions installed
    correctly
●   Eggs and other package systems not well reconciled yet;
    potential for conflicts and problems; Internet connection
    required!
●   Switching from release to SVN is tricky
Hot Topics: Deployment
●   Non-root installation requires special procedures
    (makes it difficult to deploy in a budget hosting
    environment)
●   Virtual hosting solution is yet to be determined
    (multiple sites on the same server)
●   Combining multiple TG apps into a single site is
    yet TBD
Hot Topics: Kid Issues
●   Errors in the template that cause it to be invalid
    XML will kill the CherryPy instance!
●   HTML comments in a master template cause Kid
    to barf when rendering individual templates
●   HTML entities that aren't a standard part of XML
    break Kid (unless you get clever)
●   Plain text output will be in 0.7
Hot Topics: SQLObject Issues
●   Creating tables with foreign-key dependencies on each
    other is tricky due to alphabetical order of creation; fixed
    in the forthcoming 0.8
●   Awkward for efficiently accessing multi-table data sets
●   SQLObject is not designed for statistics/reporting
●   SQLObject can be too active in database activity
●   Effort underway to examine Hibernate (a very powerful
    open source ORM from Java) and beef up SQLObject
●   API cleanup is scheduled for the 0.8 release
Hot Topics: Forms & Validation
●   Current state of form validation sucks
●   FormEncode validators are part of the
    @turbogears.expose() decorator; cumbersome for
    large forms
●   If validation fails, a special method named
    validation_error() will be called with arguments:
     –   String with the name of the original method
     –   Dictionary of arguments passed to the original method
     –   List of validation exceptions that were raised
●   No validation_error() => exception! Boom!
Hot Topics: Forms & Validation
●   Coming soon: widgets!
●   Widgets live in Python code, rendered by Kid
    templates
●   Forms will be a particular kind of widget, made
    up of other widgets:
    myform = TableForm(widgets=[
        widgets.TextField(“name”),
        widgets.TextField(“address”),
        widgets.TextField(“age”, default=0, 
            validator=validators.int())])
Hot Topics: Forms & Validation
●   Or by popular demand, a form might instead be a
    class instead of an instance:
    class myform(TableForm):
        name = widgets.TextField(“name”)
        address = widgets.TextField(“address”)
        age = widgets.TextField(default=0, 
            validator=validators.int())
Hot Topics: Forms & Validation
●   Display a form using a form widget:
    @turbogears.expose(html=”foo”)
    def index(self):
        return dict(form=myform)

    <div py:replace=”form.insert(action=”save”)”/>

●   Validate a form using a form widget:
    @turbogears.expose(input_form=myform)
    def save(self, name, address, age, has_errors):
        if has_errors:
            return self.index() # or do whatever
Hot Topics: Forms & Generation
●   Recently up for discussion: generating the rendered
    form based on the widgets as a “kick-start” to building
    templates
●   Output would probably require customization before
    being deployed
●   Automatic generation would give a designer a starting
    point without having to build the form up from nothing
●   What happens when the Python changes—regenerate
    and re-customize the form?
Dive On In!
●   Starting points on the web:
    –   http://www.turbogears.org/docs/
    –   http://www.turbogears.org/docs/gettingstarted.html
    –   http://www.turbogears.org/docs/wiki20.html
●   Google group:
    http://groups.google.com/group/turbogears/
●   #turbogears channel on irc.freenode.net
●   Aggregate blog: http://planet.turbogears.org
Contributing
●   Sprints—Ann Arbor, online, PyCon
●   How to contribute?
    –   http://www.turbogears.org/community/contributing.html
●   Contributions should be written to PEP8
    –   http://www.python.org/peps/pep-0008.html
●   Wiki & ticket system: http://trac.turbogears.org
Op/Ed
●   Not ready for prime time—wait for 1.0 if you
    need to do serious work (if you can)
●   Maturing rapidly, very exciting!
●   TG is definitely on the “short list” for how to do
    web apps in Python—Michelle's hypothetical
    Brian will be happy!
●   Good opportunity to shape a major project

More Related Content

What's hot

LvivPy - Flask in details
LvivPy - Flask in detailsLvivPy - Flask in details
LvivPy - Flask in detailsMax Klymyshyn
 
Phing for power users - dpc_uncon13
Phing for power users - dpc_uncon13Phing for power users - dpc_uncon13
Phing for power users - dpc_uncon13Stephan Hochdörfer
 
Offline strategies for HTML5 web applications - IPC12
Offline strategies for HTML5 web applications - IPC12Offline strategies for HTML5 web applications - IPC12
Offline strategies for HTML5 web applications - IPC12Stephan Hochdörfer
 
How to make Ajax work for you
How to make Ajax work for youHow to make Ajax work for you
How to make Ajax work for youSimon Willison
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture IntroductionHaiqi Chen
 
HTML5, The Open Web, and what it means for you - Altran
HTML5, The Open Web, and what it means for you - AltranHTML5, The Open Web, and what it means for you - Altran
HTML5, The Open Web, and what it means for you - AltranRobert Nyman
 
High Performance Kick Ass Web Apps (JavaScript edition)
High Performance Kick Ass Web Apps (JavaScript edition)High Performance Kick Ass Web Apps (JavaScript edition)
High Performance Kick Ass Web Apps (JavaScript edition)Stoyan Stefanov
 
Best Practices for Front-End Django Developers
Best Practices for Front-End Django DevelopersBest Practices for Front-End Django Developers
Best Practices for Front-End Django DevelopersChristine Cheung
 
Build website in_django
Build website in_django Build website in_django
Build website in_django swee meng ng
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flaskjuzten
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for BeginnersJason Davies
 
Offline Strategies for HTML5 Web Applications - oscon13
Offline Strategies for HTML5 Web Applications - oscon13Offline Strategies for HTML5 Web Applications - oscon13
Offline Strategies for HTML5 Web Applications - oscon13Stephan Hochdörfer
 
Experience Manager 6 Developer Features - Highlights
Experience Manager 6 Developer Features - HighlightsExperience Manager 6 Developer Features - Highlights
Experience Manager 6 Developer Features - HighlightsCédric Hüsler
 
Introduction to VueJS & The WordPress REST API
Introduction to VueJS & The WordPress REST APIIntroduction to VueJS & The WordPress REST API
Introduction to VueJS & The WordPress REST APICaldera Labs
 
Energy ~ nikola tesla secret ~ 9 79% conv ~ 100% comm of $110 sale teslaecoe...
Energy ~ nikola tesla secret ~ 9 79% conv ~ 100% comm of $110 sale  teslaecoe...Energy ~ nikola tesla secret ~ 9 79% conv ~ 100% comm of $110 sale  teslaecoe...
Energy ~ nikola tesla secret ~ 9 79% conv ~ 100% comm of $110 sale teslaecoe...Miroslav Miskovic
 

What's hot (20)

LvivPy - Flask in details
LvivPy - Flask in detailsLvivPy - Flask in details
LvivPy - Flask in details
 
Phing for power users - dpc_uncon13
Phing for power users - dpc_uncon13Phing for power users - dpc_uncon13
Phing for power users - dpc_uncon13
 
Offline strategies for HTML5 web applications - IPC12
Offline strategies for HTML5 web applications - IPC12Offline strategies for HTML5 web applications - IPC12
Offline strategies for HTML5 web applications - IPC12
 
How to make Ajax work for you
How to make Ajax work for youHow to make Ajax work for you
How to make Ajax work for you
 
Free django
Free djangoFree django
Free django
 
Django Architecture Introduction
Django Architecture IntroductionDjango Architecture Introduction
Django Architecture Introduction
 
HTML5, The Open Web, and what it means for you - Altran
HTML5, The Open Web, and what it means for you - AltranHTML5, The Open Web, and what it means for you - Altran
HTML5, The Open Web, and what it means for you - Altran
 
High Performance Kick Ass Web Apps (JavaScript edition)
High Performance Kick Ass Web Apps (JavaScript edition)High Performance Kick Ass Web Apps (JavaScript edition)
High Performance Kick Ass Web Apps (JavaScript edition)
 
Best Practices for Front-End Django Developers
Best Practices for Front-End Django DevelopersBest Practices for Front-End Django Developers
Best Practices for Front-End Django Developers
 
Build website in_django
Build website in_django Build website in_django
Build website in_django
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for Beginners
 
What is HTML 5?
What is HTML 5?What is HTML 5?
What is HTML 5?
 
Writing Pluggable Software
Writing Pluggable SoftwareWriting Pluggable Software
Writing Pluggable Software
 
Offline Strategies for HTML5 Web Applications - oscon13
Offline Strategies for HTML5 Web Applications - oscon13Offline Strategies for HTML5 Web Applications - oscon13
Offline Strategies for HTML5 Web Applications - oscon13
 
Experience Manager 6 Developer Features - Highlights
Experience Manager 6 Developer Features - HighlightsExperience Manager 6 Developer Features - Highlights
Experience Manager 6 Developer Features - Highlights
 
Introduction to VueJS & The WordPress REST API
Introduction to VueJS & The WordPress REST APIIntroduction to VueJS & The WordPress REST API
Introduction to VueJS & The WordPress REST API
 
Energy ~ nikola tesla secret ~ 9 79% conv ~ 100% comm of $110 sale teslaecoe...
Energy ~ nikola tesla secret ~ 9 79% conv ~ 100% comm of $110 sale  teslaecoe...Energy ~ nikola tesla secret ~ 9 79% conv ~ 100% comm of $110 sale  teslaecoe...
Energy ~ nikola tesla secret ~ 9 79% conv ~ 100% comm of $110 sale teslaecoe...
 
Perlbal Tutorial
Perlbal TutorialPerlbal Tutorial
Perlbal Tutorial
 
Intro to Laravel 4
Intro to Laravel 4Intro to Laravel 4
Intro to Laravel 4
 

Viewers also liked

Docker Security and Content Trust
Docker Security and Content TrustDocker Security and Content Trust
Docker Security and Content Trustehazlett
 
Building Distributed Systems without Docker, Using Docker Plumbing Projects -...
Building Distributed Systems without Docker, Using Docker Plumbing Projects -...Building Distributed Systems without Docker, Using Docker Plumbing Projects -...
Building Distributed Systems without Docker, Using Docker Plumbing Projects -...Patrick Chanezon
 
Secure Software Distribution in an Adversarial World
Secure Software Distribution in an Adversarial WorldSecure Software Distribution in an Adversarial World
Secure Software Distribution in an Adversarial WorldDiogo Mónica
 
Docker security: Rolling out Trust in your container
Docker security: Rolling out Trust in your containerDocker security: Rolling out Trust in your container
Docker security: Rolling out Trust in your containerRonak Kogta
 
Docker Security Overview
Docker Security OverviewDocker Security Overview
Docker Security OverviewSreenivas Makam
 
Securing your Containers (Meetup at Docker HQ 4/7)
Securing your Containers (Meetup at Docker HQ 4/7)Securing your Containers (Meetup at Docker HQ 4/7)
Securing your Containers (Meetup at Docker HQ 4/7)Docker, Inc.
 
Docker Global Hack Day #3
Docker Global Hack Day #3 Docker Global Hack Day #3
Docker Global Hack Day #3 Docker, Inc.
 
Securing the Container Pipeline at Salesforce by Cem Gurkok
Securing the Container Pipeline at Salesforce by Cem Gurkok   Securing the Container Pipeline at Salesforce by Cem Gurkok
Securing the Container Pipeline at Salesforce by Cem Gurkok Docker, Inc.
 
Dockercon EU 2015 Recap
Dockercon EU 2015 RecapDockercon EU 2015 Recap
Dockercon EU 2015 RecapLee Calcote
 
Talking TUF: Securing Software Distribution
Talking TUF: Securing Software DistributionTalking TUF: Securing Software Distribution
Talking TUF: Securing Software DistributionDocker, Inc.
 
Unikernels: the rise of the library hypervisor in MirageOS
Unikernels: the rise of the library hypervisor in MirageOSUnikernels: the rise of the library hypervisor in MirageOS
Unikernels: the rise of the library hypervisor in MirageOSDocker, Inc.
 
Docker Security Deep Dive by Ying Li and David Lawrence
Docker Security Deep Dive by Ying Li and David LawrenceDocker Security Deep Dive by Ying Li and David Lawrence
Docker Security Deep Dive by Ying Li and David LawrenceDocker, Inc.
 
Docker London: Container Security
Docker London: Container SecurityDocker London: Container Security
Docker London: Container SecurityPhil Estes
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slidesDocker, Inc.
 
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...Jérôme Petazzoni
 

Viewers also liked (16)

Docker Security and Content Trust
Docker Security and Content TrustDocker Security and Content Trust
Docker Security and Content Trust
 
Building Distributed Systems without Docker, Using Docker Plumbing Projects -...
Building Distributed Systems without Docker, Using Docker Plumbing Projects -...Building Distributed Systems without Docker, Using Docker Plumbing Projects -...
Building Distributed Systems without Docker, Using Docker Plumbing Projects -...
 
Secure Software Distribution in an Adversarial World
Secure Software Distribution in an Adversarial WorldSecure Software Distribution in an Adversarial World
Secure Software Distribution in an Adversarial World
 
Docker security: Rolling out Trust in your container
Docker security: Rolling out Trust in your containerDocker security: Rolling out Trust in your container
Docker security: Rolling out Trust in your container
 
Docker Security Overview
Docker Security OverviewDocker Security Overview
Docker Security Overview
 
Securing your Containers (Meetup at Docker HQ 4/7)
Securing your Containers (Meetup at Docker HQ 4/7)Securing your Containers (Meetup at Docker HQ 4/7)
Securing your Containers (Meetup at Docker HQ 4/7)
 
Docker Global Hack Day #3
Docker Global Hack Day #3 Docker Global Hack Day #3
Docker Global Hack Day #3
 
Securing the Container Pipeline at Salesforce by Cem Gurkok
Securing the Container Pipeline at Salesforce by Cem Gurkok   Securing the Container Pipeline at Salesforce by Cem Gurkok
Securing the Container Pipeline at Salesforce by Cem Gurkok
 
Dockercon EU 2015 Recap
Dockercon EU 2015 RecapDockercon EU 2015 Recap
Dockercon EU 2015 Recap
 
Talking TUF: Securing Software Distribution
Talking TUF: Securing Software DistributionTalking TUF: Securing Software Distribution
Talking TUF: Securing Software Distribution
 
Unikernels: the rise of the library hypervisor in MirageOS
Unikernels: the rise of the library hypervisor in MirageOSUnikernels: the rise of the library hypervisor in MirageOS
Unikernels: the rise of the library hypervisor in MirageOS
 
Docker Security Deep Dive by Ying Li and David Lawrence
Docker Security Deep Dive by Ying Li and David LawrenceDocker Security Deep Dive by Ying Li and David Lawrence
Docker Security Deep Dive by Ying Li and David Lawrence
 
Docker London: Container Security
Docker London: Container SecurityDocker London: Container Security
Docker London: Container Security
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...
 
Resume
ResumeResume
Resume
 

Similar to Turbogears Presentation

Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel Engine Yard
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 
Systems Automation with Puppet
Systems Automation with PuppetSystems Automation with Puppet
Systems Automation with Puppetelliando dias
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosIgor Sobreira
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalystsvilen.ivanov
 
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and BeyondWebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyondmguillem
 
Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)Joao Lucas Santana
 
Functional FIPS: Learning PHP for Drupal Theming
Functional FIPS: Learning PHP for Drupal ThemingFunctional FIPS: Learning PHP for Drupal Theming
Functional FIPS: Learning PHP for Drupal ThemingEmma Jane Hogbin Westby
 
yusukebe in Yokohama.pm 090909
yusukebe in Yokohama.pm 090909yusukebe in Yokohama.pm 090909
yusukebe in Yokohama.pm 090909Yusuke Wada
 
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fastHow Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fastAtlassian
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2fishwarter
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2fishwarter
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2fishwarter
 

Similar to Turbogears Presentation (20)

Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel Rails Antipatterns | Open Session with Chad Pytel
Rails Antipatterns | Open Session with Chad Pytel
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
Systems Automation with Puppet
Systems Automation with PuppetSystems Automation with Puppet
Systems Automation with Puppet
 
Django - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazosDjango - Framework web para perfeccionistas com prazos
Django - Framework web para perfeccionistas com prazos
 
Web applications with Catalyst
Web applications with CatalystWeb applications with Catalyst
Web applications with Catalyst
 
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and BeyondWebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
WebTest - Efficient Functional Web Testing with HtmlUnit and Beyond
 
T5 Oli Aro
T5 Oli AroT5 Oli Aro
T5 Oli Aro
 
Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)Desenvolvimento web com Ruby on Rails (parte 2)
Desenvolvimento web com Ruby on Rails (parte 2)
 
Api Design
Api DesignApi Design
Api Design
 
SearchMonkey
SearchMonkeySearchMonkey
SearchMonkey
 
Mojolicious
MojoliciousMojolicious
Mojolicious
 
Functional FIPS: Learning PHP for Drupal Theming
Functional FIPS: Learning PHP for Drupal ThemingFunctional FIPS: Learning PHP for Drupal Theming
Functional FIPS: Learning PHP for Drupal Theming
 
yusukebe in Yokohama.pm 090909
yusukebe in Yokohama.pm 090909yusukebe in Yokohama.pm 090909
yusukebe in Yokohama.pm 090909
 
สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1
 
Test upload
Test uploadTest upload
Test upload
 
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fastHow Bitbucket Pipelines Loads Connect UI Assets Super-fast
How Bitbucket Pipelines Loads Connect UI Assets Super-fast
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
Revoke-Obfuscation
Revoke-ObfuscationRevoke-Obfuscation
Revoke-Obfuscation
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 

More from didip

Oregon Measure 66
Oregon Measure 66Oregon Measure 66
Oregon Measure 66didip
 
High Performance Erlang
High Performance ErlangHigh Performance Erlang
High Performance Erlangdidip
 
Why I Love Python
Why I Love PythonWhy I Love Python
Why I Love Pythondidip
 
Ecma 262
Ecma 262Ecma 262
Ecma 262didip
 
Socket Programming In Python
Socket Programming In PythonSocket Programming In Python
Socket Programming In Pythondidip
 
Google Research Paper
Google Research PaperGoogle Research Paper
Google Research Paperdidip
 
Feed Burner Scalability
Feed Burner ScalabilityFeed Burner Scalability
Feed Burner Scalabilitydidip
 
Theory Psyco
Theory PsycoTheory Psyco
Theory Psycodidip
 
Super Sizing Youtube with Python
Super Sizing Youtube with PythonSuper Sizing Youtube with Python
Super Sizing Youtube with Pythondidip
 

More from didip (9)

Oregon Measure 66
Oregon Measure 66Oregon Measure 66
Oregon Measure 66
 
High Performance Erlang
High Performance ErlangHigh Performance Erlang
High Performance Erlang
 
Why I Love Python
Why I Love PythonWhy I Love Python
Why I Love Python
 
Ecma 262
Ecma 262Ecma 262
Ecma 262
 
Socket Programming In Python
Socket Programming In PythonSocket Programming In Python
Socket Programming In Python
 
Google Research Paper
Google Research PaperGoogle Research Paper
Google Research Paper
 
Feed Burner Scalability
Feed Burner ScalabilityFeed Burner Scalability
Feed Burner Scalability
 
Theory Psyco
Theory PsycoTheory Psyco
Theory Psyco
 
Super Sizing Youtube with Python
Super Sizing Youtube with PythonSuper Sizing Youtube with Python
Super Sizing Youtube with Python
 

Recently uploaded

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Turbogears Presentation

  • 1. Introduction to TurboGears Mike Pirnat Clepy Meeting: 11/07/2005 http://www.pirnat.com/geek/
  • 2. What, Another Python Framework?? “You're not a Real Python Programmer until you've written your own web templating toolkit.” -- Moshe Zadka “Stop writing kewl new frameworks! Help improve the top few frameworks so they can become a best of breed.” -- Michelle Levesque
  • 3. What is TurboGears? ● Python “megaframework” for web apps ● Pythonic answer to Ruby on Rails ● Rapid web development ● Rapidly growing community—over 500 users on the mailing list since late September! ● Not afraid of “Not Invented Here” ● Under heavy development ● Shiny and new... or is it?
  • 4. TurboGears Philosophy ● Create great web apps faster, easier, and more fun ● Use the best available existing components ● Combine in an easy-to-use package ● Deliver an excellent out-of-box experience ● MVC == good ● Eliminate tedium with abstraction, tools ● TurboGears provides the “glue” so that you don't have to make your own
  • 5. TurboGears Components ● Database ORM access: SQLObject ● Application server: CherryPy ● Template engine: Kid ● Javascript/AJAX library: MochiKit ● Automated testing: TestGears, Nose
  • 6.
  • 7. TurboGears Kickstarts Your App ● Create a new project and directory structure with tg­admin quickstart ● Start your server with python PROJECT­start.py (created by quickstart in the root of your app) ● Your install is now up and running at: http://localhost:8080/! ● Set up your dev.cfg (created automatically) with database connection string ● Define your data model using SQLObject subclasses, then run tg­admin sql create ● Then the fun part begins!
  • 8. SQLObject ● Object Relational Manager ● Database tables are classes, rows are instances, fields are attributes ● Eliminates need to write SQL by hand (mostly) ● Use with MySQL, PostgreSQL, sqlite, Firebird ● Sybase and Oracle support in progress ● Can generate DB from Python, or Python from DB!
  • 9. SQLObject ● Supports joins, one-to-many, and many-to-many relationships ● Supports transactions ● Can do lazy updates to minimize DB chatter ● Result sets are lazily evaluated generators ● Result sets can be sliced => different SQL ● Caches objects retrieved from DB ● Can still do full-on SQL if needed ● http://sqlobject.org/
  • 11. CherryPy ● Pythonic, objected-oriented web app framework ● Maps URL request to a Python method using decorators ● CGI variables are mapped to method arguments ● Does not support SSL natively; put it behind Apache with mod_proxy or mod_python to allow secure traffic ● http://www.cherrypy.org
  • 13. CherryPy/TurboGears: Examples import cherrypy import turbogears from turbogears import controllers class MyRoot: class MyRoot(controllers.Root):     @cherrypy.expose()     def index(self, who=”World”):     @turbogears.expose(html=”foo”)         return “Hello, %s!” % who     def index(self, who=”World”):         return dict(who=who)
  • 14. Kid ● Templates are well-formed XML ● Attribute language similar to Zope's TAL ● Compiled to Python byte-code ● Processed using a pull-style parser based on ElementTree ● Supports template inheritance and XSLT-like matching ● Designer-friendly: viewable in browser ● http://kid.lesscode.org
  • 15. Kid: Example <?python <?xml version=quot;1.0quot; encoding=quot;utf­8quot;?> title = quot;A Kid Test Documentquot; <html> fruits = [quot;applequot;, quot;orangequot;, quot;kiwiquot;, quot;M&Mquot;]   <head> from platform import system     <title>A Kid Test Document</title> ?>   </head> <html xmlns:py=quot;http://purl.org/kid/ns#quot;>   <body>   <head>     <p>These are some of my favorite      <title py:content=quot;titlequot;>This is  fruits:</p> replaced.</title>     <ul>   </head>       <li>I like apples</li>   <body>       <li>I like oranges</li>     <p>These are some of my favorite        <li>I like kiwis</li> fruits:</p>       <li>I like M&amp;Ms</li>     <ul>     </ul>       <li py:for=quot;fruit in fruitsquot;>     <p>         I like ${fruit}s       Good for you!       </li>     </p>     </ul>   </body>     <p py:if=quot;system() == 'Linux'quot;> </html>       Good for you!     </p>   </body> </html>
  • 16. Kid: Template Inheritance ● Master template defines a “template function” <div py:def=”header(title)”>   <h1>${title}</h1> </div> ● Individual templates extend the master and call the function: <html py:extends=”'common.kid'”> ... <div py:replace=”header('Foo!')”>This will be  replaced</div> ... </html>
  • 17. Kid: Matching ● Individual templates extend from master ● Master template defines a matching rule: <body py:match=”item.tag=='{http://www.w3.org/1999/xhtml} body'”>   <h1>${title}</h1>   <div py:replace=”item[:]”>
  • 18. MochiKit ● Pythonic JavaScript library ● “Makes JavaScript suck less” ● Well-documented ● Reliable (lots of automated tests) ● Single JS import to have access to all features ● Features galore... ● http://mochikit.com
  • 19. MochiKit: Features ● Asynchronous tasks ● Iteration (ala Python's ● DOM manipulation itertools) ● Color abstraction ● Logging ● Date and time ● Interactive JavaScript shell ● String formatting ● Visual effects
  • 20. MochiKit: Sorting & Accessing myObjectArray = [   {“a”: 3, “b”: 2},   {“a”: 1, “b”: 2} ]; // sort by the “a” property myObjectArray.sort(keyComparator(“a”)); // get just the “a” values out into an array sortedAValues = map(itemgetter(“a”), myObjectArray);
  • 22. Testing: TestGears and Nose ● TurboGears up to 0.8: TestGears ● TurboGears 0.9+ will use Nose ● Both are unittest extensions that mimic the behavior and ease-of-use of py.test ● Automated test discovery and execution ● More info: – http://www.turbogears.org/testgears – http://somethingaboutorange.com/mrl/projects/nose
  • 23. TestGears ● Where to put tests? Generally in a “tests” package in your project ● Running tests? At the top level directory of your project, run: python setup.py testgears ● Testing methods: – Directly – Simulating a web request
  • 25. TestGears: Simulating a Web Request from turbogears import util from myproject.controllers import Root import cherrypy def test_indextitle_in_template():     “””Index template should have a title.”””     cherrypy.root = Root()     util.createRequest('/')     assert “<title>Foobar</title>” in              cherrypy.response.body[0]
  • 26. The Infamous 20-Minute Wiki ● How do we put components together? ● How quickly can we make an app? ● Would you believe... a usable wiki in 20 minutes? ● “Screencast” inspired by the Ruby on Rails introductory video – http://www.turbogears.org/docs/wiki20/20MinuteWiki.mov – http://www.turbogears.org/docs/wiki20/index.html
  • 27. Current “Hot Topics” ● CRUD ● Identity ● Installation, Upgrading, Deployment ● Kid issues ● SQLObject issues ● Forms: Validation & Generation
  • 28. Hot Topics: CRUD ● CRUD = Create, Retrieve, Update, Delete ● TG wanted to include “free CRUD” ala Django and Rails ● Several groups started in their own directions ● When suddenly... along came CatWalk! – Manage and interact with your TG models from a browser – http://checkandshare.com/catwalk/ – Now included with TurboGears SVN – Will be bundled in 0.9+
  • 29. Hot Topics: Identity ● Jeff Watkins is producing an identity framework for TurboGears ● Should be ready for TG 0.9 ● User, group, permission scheme ● IP-based access control ● Should be interchangeable with other preferred/required identity models which implement a consistent interface ● http://newburyportion.com/nerd/2005/10/identity-management-for-turbogears
  • 30. Hot Topics: Installation & Upgrading ● Initial installation is easy thanks to Easy Install: sudo python ez_setup.py ­f http://www.turbogears.org/download/index.html      ­­script­dir /usr/local/bin TurboGears ● TG and friends are distributed as Python Eggs ● Upgrading has been tricky, often requiring updates to the update framework in order to get the latest versions installed correctly ● Eggs and other package systems not well reconciled yet; potential for conflicts and problems; Internet connection required! ● Switching from release to SVN is tricky
  • 31. Hot Topics: Deployment ● Non-root installation requires special procedures (makes it difficult to deploy in a budget hosting environment) ● Virtual hosting solution is yet to be determined (multiple sites on the same server) ● Combining multiple TG apps into a single site is yet TBD
  • 32. Hot Topics: Kid Issues ● Errors in the template that cause it to be invalid XML will kill the CherryPy instance! ● HTML comments in a master template cause Kid to barf when rendering individual templates ● HTML entities that aren't a standard part of XML break Kid (unless you get clever) ● Plain text output will be in 0.7
  • 33. Hot Topics: SQLObject Issues ● Creating tables with foreign-key dependencies on each other is tricky due to alphabetical order of creation; fixed in the forthcoming 0.8 ● Awkward for efficiently accessing multi-table data sets ● SQLObject is not designed for statistics/reporting ● SQLObject can be too active in database activity ● Effort underway to examine Hibernate (a very powerful open source ORM from Java) and beef up SQLObject ● API cleanup is scheduled for the 0.8 release
  • 34. Hot Topics: Forms & Validation ● Current state of form validation sucks ● FormEncode validators are part of the @turbogears.expose() decorator; cumbersome for large forms ● If validation fails, a special method named validation_error() will be called with arguments: – String with the name of the original method – Dictionary of arguments passed to the original method – List of validation exceptions that were raised ● No validation_error() => exception! Boom!
  • 35. Hot Topics: Forms & Validation ● Coming soon: widgets! ● Widgets live in Python code, rendered by Kid templates ● Forms will be a particular kind of widget, made up of other widgets: myform = TableForm(widgets=[     widgets.TextField(“name”),     widgets.TextField(“address”),     widgets.TextField(“age”, default=0,          validator=validators.int())])
  • 36. Hot Topics: Forms & Validation ● Or by popular demand, a form might instead be a class instead of an instance: class myform(TableForm):     name = widgets.TextField(“name”)     address = widgets.TextField(“address”)     age = widgets.TextField(default=0,          validator=validators.int())
  • 37. Hot Topics: Forms & Validation ● Display a form using a form widget: @turbogears.expose(html=”foo”) def index(self):     return dict(form=myform) <div py:replace=”form.insert(action=”save”)”/> ● Validate a form using a form widget: @turbogears.expose(input_form=myform) def save(self, name, address, age, has_errors):     if has_errors:         return self.index() # or do whatever
  • 38. Hot Topics: Forms & Generation ● Recently up for discussion: generating the rendered form based on the widgets as a “kick-start” to building templates ● Output would probably require customization before being deployed ● Automatic generation would give a designer a starting point without having to build the form up from nothing ● What happens when the Python changes—regenerate and re-customize the form?
  • 39. Dive On In! ● Starting points on the web: – http://www.turbogears.org/docs/ – http://www.turbogears.org/docs/gettingstarted.html – http://www.turbogears.org/docs/wiki20.html ● Google group: http://groups.google.com/group/turbogears/ ● #turbogears channel on irc.freenode.net ● Aggregate blog: http://planet.turbogears.org
  • 40. Contributing ● Sprints—Ann Arbor, online, PyCon ● How to contribute? – http://www.turbogears.org/community/contributing.html ● Contributions should be written to PEP8 – http://www.python.org/peps/pep-0008.html ● Wiki & ticket system: http://trac.turbogears.org
  • 41. Op/Ed ● Not ready for prime time—wait for 1.0 if you need to do serious work (if you can) ● Maturing rapidly, very exciting! ● TG is definitely on the “short list” for how to do web apps in Python—Michelle's hypothetical Brian will be happy! ● Good opportunity to shape a major project