Source

rudixweb / main.py

Full commit
#!/usr/bin/env python2.5

import bottle
from bottle import route, view
from google.appengine.ext import db
from markdown import markdown

bottle.debug(True)

class Port(db.Model):
    name = db.StringProperty()
    title = db.StringProperty()
    summary = db.StringProperty()
    description = db.TextProperty()
    site = db.StringProperty()
    version = db.StringProperty()
    revision = db.StringProperty()
    license = db.StringProperty()


@route('/packages/:package')
@view('package_info')
def package_info(package):
    port = db.GqlQuery('SELECT * FROM Port WHERE name = :1', package)[0]
    res = dict((name, getattr(port, name)) for name in port.properties())
    res['description'] = markdown(res['description'])
    return res

@route('/packages/')
@view('package_list')
def package_list():
    ports = db.GqlQuery('SELECT * FROM Port ORDER BY name')
    return {'packages': ports}

@route('/')
@view('index')
def index():
    return {"a": 2}


def main():
    bottle.run(server='gae')