While redoing my own damn tutorial I'm running into a problem that has to 
be painfully obvious to anyone on the world but me. I get the message 
"NameError: name 'post' is not defined" when I try to do a /new in the 
following conditions. What idiocy am I committing here?

*file models.py:*
from .common import db, Field
from pydal.validators import *

db.define_table('post',  
    Field('title','string',notnull=True),
    Field('url', 'text',IS_URL()),
    Field('body','string'))

db.commit()

*new.html:*
[[extend 'layout.html']]
<h1>[[=post.title]]</h1>
<p>[[=post.body]]</p>
[[=A('Home', _href=URL('index'))]]

*post.html:*
[[extend 'layout.html']]
<h1>[[=post.title]]</h1>
<p>[[=post.body]]</p>
[[=A('Home', _href=URL('index'))]]

*In controllers.py:*
@action("post/<id>")
@action.uses('post.html')
def post(id):
    post=db.post(id)
    form=Form(db.post,post)
    return dict(post=post,form=form)

@action('new',method=['GET','POST'])    
@action.uses(auth,flash,session,'new.html')
def new():
    form=Form(db.post)
    if form.accepted:
        redirect(URL('index'))
    elif form.errors:
        flash.set('You\'ll need either a URL or a comment', class_="error")
    return dict(form=form)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/315118f9-8d37-4f8d-b5ae-2961e958b311n%40googlegroups.com.

Reply via email to