seedifferently/the-great-web-framework-shootout — Issue #14: add web2py
Author: mdipierro
Created: 2012-02-20 05:25:44+00:00
State: open

wget http://web2py.com/examples/static/web2py_src.zip
unzip web2py_src.zip
cd web2py
mkdir applications/benchmark
cp -r applications/welcome/* applications/benchmark
rm applications/benchmark/models/*
echo """
import sqlite3

def index():
return 'Hello World!'

def hellos():
return dict()

def hellodb(): # NO DAL
db = sqlite3.connect(os.path.join(request.folder,'databases','hello.db'))
rows = db.execute('select id, data from hello order by id asc')
lipsum = [dict(id=row[0], data=row[1]) for row in rows.fetchall()]
return dict(rows=lipsum)

def hellodb2(): # DAL
response.view = 'tests/hellodb.html' # recycle view
db = DAL('sqlite://hello.db')
db.define_table('hello',Field('data')) # creates table and db if not exists
rows = db(db.hello).select()
return dict(rows=rows)
""" > applications/benchmark/controllers/tests.py
mkdir applications/benchmark/views/tests
echo """

Hello World

{{ include }}

""" > applications/benchmark/views/base.html
echo """
{{ extend "base.html" }}

Lorem ipsum dolor sit amet, consecteteur adipiscing elit nisi ultricies. Condimentum vel, at augue nibh sed. Diam praesent metus ut eros, sem penatibus. Pellentesque. Fusce odio posuere litora non integer habitant proin. Metus accumsan nibh facilisis nostra lobortis cum diam tellus. Malesuada nostra a volutpat pede primis congue nisl feugiat in fermentum. Orci in hymenaeos. Eni tempus mi mollis lacinia orci interdum lacus. Sollicitudin aliquet, etiam. Ac. Mi, nullam ligula, tristique penatibus nisi eros nisl pede pharetra congue, aptent nulla, rhoncus tellus morbi, ornare. Magna condimentum erat turpis. Fusce arcu ve suscipit nisi phasellus rutrum a dictumst leo, laoreet dui, ultricies platea. Porta venenatis fringilla vestibulum arcu etiam condimentum non.

""" > applications/benchmark/views/tests/hellos.html
echo """
{{ extend "base.html" }}

Lorem ipsum dolor sit amet, consecteteur adipiscing elit nisi ultricies. Condimentum vel, at augue nibh sed. Diam praesent metus ut eros, sem penatibus. Pellentesque. Fusce odio posuere litora non integer habitant proin. Metus accumsan nibh facilisis nostra lobortis cum diam tellus. Malesuada nostra a volutpat pede primis congue nisl feugiat in fermentum. Orci in hymenaeos. Eni tempus mi mollis lacinia orci interdum lacus. Sollicitudin aliquet, etiam. Ac. Mi, nullam ligula, tristique penatibus nisi eros nisl pede pharetra congue, aptent nulla, rhoncus tellus morbi, ornare. Magna condimentum erat turpis. Fusce arcu ve suscipit nisi phasellus rutrum a dictumst leo, laoreet dui, ultricies platea. Porta venenatis fringilla vestibulum arcu etiam condimentum non.

{{ for row in rows }}

{{=row['id']}}	{{=row['data']}}

{{ endfor }}

""" > applications/benchmark/views/tests/hellodb.html
python web2py.py -a chooseapassword &
open http://127.0.0.1:8000/benchmark/tests/hello
open http://127.0.0.1:8000/benchmark/tests/hellos
open http://127.0.0.1:8000/benchmark/tests/hellodb
open http://127.0.0.1:8000/benchmark/tests/hellodb2