MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Python/comments/d0aqk/flying_with_web2py_in_google_app_engine/c0wl91l/?context=3
r/Python • u/mdipierro • Aug 12 '10
1 comment sorted by
View all comments
3
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')]]
3
u/mdipierro Aug 12 '10 edited Aug 12 '10
Nice but a bit verbose. The entire code can be rewritten as
Model:
Controller:
You could also support MARKMIN wiki syntax simply by replacing
with
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: