[web2py] Re: how to calculate size of uploads by user

2016-01-15 Thread Niphlod
if your request.vars.something is a list, then it means that somewhere you have two fields that are coming in with the same name. trim the code to the very essential and start from there please. form = SQLFORM(db.UploadedMeetingMaterials) if request.vars.uploadedMeetingContent:

[web2py] Re: how to calculate size of uploads by user

2016-01-15 Thread Alex Glaros
I see other examples that work, that look just like Niphlod's examples and my code. Could I have environment variables set that block cgi.FieldStorage object info? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https

[web2py] Re: how to calculate size of uploads by user

2016-01-15 Thread Alex Glaros
oops, sorry, this line if form.vars.uploadedMeetingContent: is supposed to be if *request*.vars.uploadedMeetingContent: now am getting somewhere. Error says: 'list' object has no attribute 'value' -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.c

[web2py] Re: how to calculate size of uploads by user

2016-01-15 Thread Alex Glaros
here is complete code.. anyone see where the problem is? The result is the file gets uploaded, no errors raised, but the content name and file-size are "None" in the resulting record. Session flashes don't display. db.define_table('UploadedMeetingMaterials', Field('id','id', readable=

[web2py] Re: how to calculate size of uploads by user

2016-01-14 Thread Niphlod
it makes perfect sense: if if request.vars.contents results always falsy, there's no way you can request.vars.contents.value. Something smells fishy though: you can't NOT have a request variable holding your precious uploaded file. -- Resources: - http://web2py.com - http://web2py.com/book (

[web2py] Re: how to calculate size of uploads by user

2016-01-14 Thread Alex Glaros
do I need to import something to make it work? lines after if request.vars.contents: are never reached if I take out the above conditional, it doesn't know what "value" and " filesize" are 'NoneType' object has no attribute 'value' 'NoneType' object has no attribute 'filename' -- Resources: -

[web2py] Re: how to calculate size of uploads by user

2016-01-13 Thread Niphlod
detailed examples are for hard things AND people not willing to experiment :-P it's pretty simple. Given a table with Field('contents', 'upload') any submitted form will have "contents" as a FieldStorage (standard wsgi behaviour). The real deal (or, "the nifty trick") is checking BEFORE form

[web2py] Re: how to calculate size of uploads by user

2016-01-13 Thread Alex Glaros
am having trouble finding detailed examples. Can you please help with syntax? Am determining size when uploading a user's photo (thumbnail) to their profile: if form.process().accepted: session.flash = 'profile update accepted' file_info = cgi.FieldStorage(form.vars.thumbnail

[web2py] Re: how to calculate size of uploads by user

2016-01-13 Thread Niphlod
manual uploads, dude! an upload field is a cgi.FieldStorage object. len(thefieldstorage.value) or you can seek() and tell() , as IS_LENGTH does already -- Resources: - http://web2py.com - http://web2py.com/book (Documenta

[web2py] Re: how to calculate size of uploads by user

2016-01-12 Thread Alex Glaros
also tried to enter file_size within form when adding the record if form.process().accepted: session.flash = 'profile update accepted' form.vars.file_size = filesize([form.vars.thumbnail]) result was return os.stat(os.path.join(request.uploadfolder,'uploads')) File "nt

[web2py] Re: how to calculate size of uploads by user

2016-01-12 Thread Alex Glaros
Can anyone help me with syntax for computing file size and posting to metadata? Niphlod got me started in the right direction. Is this the right idea? Am trying to get file size into field file_size below: def filesize(filename): import os, stat return os.uploadfolder(os.path.join(request

[web2py] Re: how to calculate size of uploads by user

2016-01-12 Thread Niphlod
if you store the file-size as metadata it would be matter of a select sum(filesize) from thattable group by user if you choose not to do it (which I don't recommend), you'd have to retrieve the file for each user and sum the calculated size. On Tuesday, January 12, 2016 at 7:38:24 PM UTC+1, Al