1. Álvaro Justen - Turicas
  2. web2itter


web2itter / models / db.py

# coding: utf8

titles = {'pythonbrasil5': '#PythonBrasil', 'devinrio': '#DevInRio'}

response.q = request.vars.get('q', None) or None
if not response.q in titles and request.controller == 'tweets':
    redirect(URL(r=request, c='tweets', f='index?q=pythonbrasil5'))
if request.controller == 'default':
    response.title = 'Start page'
    response.q = 'default'
    response.title = titles[response.q]

db = DAL('sqlite://twitter.sqlite')

db.define_table('tweets_%s' % response.q,
    Field('author', 'string', length=140),
    Field('date', 'datetime'),
    Field('tweet', 'string', length=140),
    Field('tweet_id', 'double'),
    Field('image', 'string', length=512),
    Field('source', 'string', length=512),
#TODO: for now we need to change same code in modules/update_tweets.py, so we
# have to delete this redundacy

TABLE = db['tweets_%s' % response.q]