Is linkto and fields mutually exclusive?

22 views
Skip to first unread message

Douglas Krueger

unread,
Aug 11, 2023, 12:55:48 PM8/11/23
to web2py-users
First attempt with Wep2py, going through the book, on chapter 7 and stuck getting both the linkto object to display and have the image filename stored in the database. I can one or the other but not both. Seems they are mutally exclusive, although my 2 AI helpers say no. Couldn't find any conversations here about this. Any help would be greatly appreciated. How can I get both to work? 

Seems that if person.image.filename is allowed to be displayed in the view, then linking to the image (pressing the button) does not store the filename in the DB. Is this as designed? 

def forms():
    record = db.person(request.args(0))
    url = URL('download')
    link = URL('list_records', args='db')
    form = SQLFORM(db.person, record, deletable=True, upload=url,
                  linkto=link, labels = {'dog.owner':"This person's dogs"},
                  fields=['name', 'gender', 'married', 'profile', 'image'])
    if request.vars.image != None:
        form.vars.image_filename = request.vars.image.filename
    if form.process().accepted:
        response.flash = 'form accepted'
    elif form.errors:
        response.flash = 'form has errors'
    return dict(form=form) 

In general, I'm mystified with what and how things get passed back and forth between the controllers and the views. Probably due to my lack of webdev experience, ack. I'd be glad of any other learning resources. 
Reply all
Reply to author
Forward
0 new messages