[web2py] Re: Upload field with clear text filename

2012-12-30 Thread Alan Etkin
El viernes, 28 de diciembre de 2012 06:15:52 UTC-3, Joe Barnhart escribió: I'm not sure why this is difficult, but I see many posts about this when I search, yet none exactly work for me. This seems like it should be easy but is surprisingly difficult in web2py. A possible workaround

[web2py] Re: Upload field with clear text filename

2012-12-30 Thread Massimo Di Pierro
This form=SQLFORM(db.fileobject) if request.vars.upload: form.vars.filename = request.vars.upload.filename if form.process().accepted: ... should work. Please open a ticket. On Friday, 28 December 2012 03:15:52 UTC-6, Joe Barnhart wrote: I'm not sure why this is

[web2py] Re: Upload field with clear text filename

2012-12-30 Thread Alan Etkin
My bad: Assigning to a form.vars item before calling to .process() works The issue is that the first code posted by Joe tests for the boolean value of form.vars.upload (an instance of the file storage object) and that object always evaluates to False, so: if request.vars.update: assign to

[web2py] Re: Upload field with clear text filename

2012-12-29 Thread Joe Barnhart
I was trying to keep the filename out of the generated form since I want it set automatically in the process of uploading the document. Is there a better way to accomplish that? BTW, the test if request.vars.upload does not work. It returns False even if the upload field has been set. I had

[web2py] Re: Upload field with clear text filename

2012-12-29 Thread Anthony
Setting writable to False is probably the best way to keep that field out of the form -- that's why I suggested setting the default value of the field instead. Does that not work? Anthony On Saturday, December 29, 2012 8:04:05 PM UTC-5, Joe Barnhart wrote: I was trying to keep the filename

[web2py] Re: Upload field with clear text filename

2012-12-28 Thread Anthony
Are you saying you want the name in the filename field to be encoded into the string stored in the upload field so the file has the name in the filename field upon download? If so, then try: if request.vars.upload and request.vars.filename: request.vars.upload.filename =

[web2py] Re: Upload field with clear text filename

2012-12-28 Thread Joe Barnhart
Hi Anthony -- I want the opposite of this -- I want the actual text filename, not the encoded one. The book example I followed did not work. -- Joe On Friday, December 28, 2012 2:18:24 AM UTC-8, Anthony wrote: Are you saying you want the name in the filename field to be encoded into the

[web2py] Re: Upload field with clear text filename

2012-12-28 Thread Anthony
I see. I think the problem is that you have set the writable attribute of the filename field to False. In that case, try setting the default value of that field: if request.vars.upload: db.fileobject.filename.default = request.vars.upload.filename form = SQLFORM(db.fileobject) Anthony On