I can't seem to figure out how to do multiple tables in one form where an 
image upload is involved. I've tried various combinations of this. 
Unfortunately I'm not getting meaningful error messages right now, 
everything is listed as "timed out".

db.define_table('post',
    Field('title'),
    Field('body', 'text'))

db.define_table('image',
    Field('post_id', db.post, readable=False, writable=False),
    Field('filename', 'upload'))

def newpost():
    form = SQLFORM.factory(db.post, db.image)
    if form.process().accepted:
        post_id = db.post.insert(**db.post._filter_fields(form.vars))
        db.image.insert(post_id=post_id,
            filename=db.image.filename.store(form.vars.filename.file, 
form.vars.filename.filename))
        redirect(URL('post', args=post_id))
    return dict(form=form)

Reply via email to