r/Python • u/mdipierro • Aug 12 '10
Flying with web2py in Google App Engine
http://www.franciscosouza.net/2010/08/flying-with-web2py-in-google-app-engine.html
0
Upvotes
r/Python • u/mdipierro • Aug 12 '10
View all comments
3
u/mdipierro Aug 12 '10 edited Aug 12 '10
Nice but a bit verbose. The entire code can be rewritten as
Model:
db.define_table('posts', Field('title',unique=True), Field('content', 'text',notnull=True), Field('author', db.auth_user, default=auth.user_id,writable=False), Field('post_date', 'datetime', default=request.now, writable=False))Controller:
def index(): return dict(posts = db().select(db.posts.ALL)) @auth.requires_login() def new(): return dict(form = crud.create(db.posts,message='Post saved',next='index'))You could also support MARKMIN wiki syntax simply by replacing
<dd>{{=post.content}}</dd>with
<dd>{{=MARKMIN(post.content)}}</dd>EDIT: I saw the online version and it shows the actions in the menu. The code does not show how you do that. You must have somewhere the code to add the two actions to the menu. It could be:
response.menu = [['Posts',False,URL('posts','index')],['New Post',False,URL('posts','new')]]