more on turbogears leif oppermann 24 04 2008 n.
Skip this Video
Loading SlideShow in 5 Seconds..
More on TurboGears Leif Oppermann, 24.04.2008 PowerPoint Presentation
Download Presentation
More on TurboGears Leif Oppermann, 24.04.2008

Loading in 2 Seconds...

play fullscreen
1 / 17

More on TurboGears Leif Oppermann, 24.04.2008 - PowerPoint PPT Presentation

  • Uploaded on

More on TurboGears Leif Oppermann, 24.04.2008. Course of this lecture. Example project: Movie Collection Utilizing movie data IMDb IMDbPy Explaining Model Views Controllers. Source of data: IMDB.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'More on TurboGears Leif Oppermann, 24.04.2008' - leal

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
course of this lecture
Course of this lecture
  • Example project: Movie Collection
  • Utilizing movie data
    • IMDb
    • IMDbPy
  • Explaining
    • Model
    • Views
    • Controllers
source of data imdb
Source of data: IMDB
  • The Internet Movie Database ( is an online database of information about movies, actors, television shows, production crew personnel, and video games.
  • IMDb began October 17, 1990. In 1998, it was acquired by As of April 26, 2007, the site featured 981,916 titles (372,912 theatrically released) and 2,336,303 people.
getting imdb data
Getting IMDb data
  • IMDb *always* had a data interface

(Zipped text files over FTP server)

  • a Python implementation of the interface is available: IMDBPy
  • Remember: TurboGears uses Python!
  • IMDbPY is a Python package useful to retrieve and manage the data of the IMDb movie database about both movies and people.
  • Platform-independent and written in pure Python (and few C lines), it can retrieve data from both the IMDb's web server and a local copy of the whole database.
example project movie collection
Example project: Movie Collection
  • Idea: browse movies (with IMDB info) and store favourites with annotations
  • Functionality:
    • Search (fuzzy, showing matching titles)
    • Browse movie details
    • Store movie to favourites
    • Add a note
uses 2 databases
Uses 2 databases
  • Database #1: imdb.sqlite
    • Self generated from IMDB data
    • >11 hours parsing
    • ~ 2 GB in one file
  • Database #2: devdata.sqlite
    • Generated by Turbogears (SQLObject)
model for database 2
Model for database #2

from turbogears.database import PackageHub

from sqlobject import *

hub = PackageHub("imdb01")

__connection__ = hub

class Movie(SQLObject):

title = UnicodeCol(alternateID=True, length=40)

imdbid = UnicodeCol(alternateID=True, length=16)

director = UnicodeCol()

notes = UnicodeCol()

  • Movielist.kid
  • Search.kid
  • Browsemovie.kid
  • Edit.kid
  • Movie.kid

<div id="status_block">Showing your collection of movies</div>

<div id="sidebar">

Choose a movie or start a search

<form method="post" action="../search">

<textarea name="searchterm" rows="1" cols="25"></textarea>


<input type="submit" value="Search"/>



<div class="list">


<li py:for="title in movies"><a href="movie/${title}">${title}</a></li>






<div id="status_block">Editing note for: <span py:content="movie.title">move title goes here</span>


<div id="sidebar">

You can return to the <a href="/">Movie List</a>


or Search again

<form method="post" action="../search">

<textarea name="searchterm" rows="1" cols="25"></textarea>


<input type="submit" value="Search"/>



<div class="note">

<form method="post" action="save">

<input type="hidden" name="title" value="${movie.title}"/>

<textarea name="notes" rows="10" cols="45 ">${movie.notes}</textarea>


<input type="submit" value=„Save"/>





search controller
Search Controller


def search(self, searchterm):

i = imdb.IMDb(**IMDB_PARAMS)

# finding matching movies


# Do the search, and get the results (a list of Movie objects).

matchingtitles = i.search_movie(searchterm)

except imdb.IMDbError, e:

print "***ERROR connecting to IMDB. Complete error report:"

print e

if not matchingtitles:


return dict(searchterm=searchterm, matchingtitles = matchingtitles)

away with powerpoint
Away with Powerpoint
  • Let‘s talk about the source!
thanks for your attention
Thanks for your attention
  • Questions / Comments / Get the source:
    • Now, or via email: LXO@CS.NOTT.AC.UK
  • Blog entry for this lecture:
additional pointers
Additional pointers
  • Of course there are similar frameworks for other programming languages,  the "original" being Ruby on Rails. Original in the sense that its design was so influential that it quickly got adapted by others. Have a look at the following if you feel that you like what you saw in the lectures, but would rather do it in another language or framework:
  • (Ruby)
  • (PHP)
  • (Python)
  • (Python)
  • (Python, Django)