Unable to handle upload

44 views
Skip to first unread message

Annet

unread,
Apr 26, 2021, 9:23:00 AM4/26/21
to web2py-users
In my database model I have a parent table 'thg_thing' and a child table 'thg_book'


Furthermore I have a function book_form which contains the following code:

form = SQLFORM(db.thg_book, row, deletable=False, upload=URL('default', 'download'), showid=False, buttons=buttons)
if hasattr(request.vars.image, 'filename'):
        form.vars.imagefilename = request.vars.image.filename

if form.validate():
        if row:
            row.update_record(**db.thg_book._filter_fields(form.vars))
            if form.vars.image__delete:
                file = row.image
                os.remove(os.path.join(UPLOADSDIR, 'vertex%s' % vertexid, file))
                row.update_record(imagefilename=None, image=None, width=None, height=None)

        form.vars.thingid = db.thg_thing.insert(name=form.vars.h1selector)
        db.thg_book.insert(**db.thg_book._filter_fields(form.vars))


Now when I submit the form, I get the following error:

db.thg_book.insert(**db.thg_book._filter_fields(form.vars))

raise RuntimeError("Unable to handle upload")
RuntimeError: Unable to handle upload


I don't understand why I het this error, is it because I use form.validate()
instead of if form.process().accepted:

Kind regards,

Annet



Reply all
Reply to author
Forward
0 new messages