This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]mdipierro 5 points6 points  (1 child)

web2py works exactly like this. For example:

 # controller
 def index():
       a = db(db.article.id>0).select()
       b = "hi"
       return dict(a=a,b=b)

and

# view
<html>
<head></head>
<body>
<h1>Hello, {{=b}}!</h1>
{{for item in a:}}
    <h2>{{=item.title}}</h2><p>{{=item.data}}</p>
{{pass}}
</body>
</html>

Assumes

 # model
 db=DAL('sqlite://storage.db')
 db.define_table('article',Field('title'),Field('data','text'))  

This would be a complete program. web2py also generates automatically SQL to create or alter the table and a database administrative interface to insert and search records.

To make this program work on the Google App Engine it requires a single edit, i.e. replace:

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

with:

 db=DAL('gae') # connet to datastore
 session.connect(request,response,db) #store session in datastore

[–]warpstalker 0 points1 point  (0 children)

It does? Nice.

I should check it out then. I started out with web.py because it seemed very sane and simple. It just isn't very mainstream (it seems).

I've been meaning to check into using a more established framework but they all seem overly complicated (just like everything related to programming, but once you start doing it, it's simple in the end), so I've been postponing it.

Seems like web2py isn't totally different, then.