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)