Uploading a file under the Static section of web2py admin gets exception

24 views
Skip to first unread message

Davidiam

unread,
Oct 22, 2019, 5:08:07 AM10/22/19
to web...@googlegroups.com
Hello,

I am trying to upload files via the Welcome appadmin in the Static files section, but the uploads are failing with "Cannot upload file <filename>"

I have now traced this in Pycharm and it is failing on the call to the count_lines method in the admin\controllers\default.py 

In the debugger I see the message "AttributeError: 'dict" object has no attribulte 'len'"

Admin\Controllers\default.py :

upload_file method calls count_lines method with the data from the file


data variable contains :

b"from pyspark.sql.functions import udf\r\nfrom pyspark.sql.types import IntegerType, StringType\r\n\r\n\r\n@udf(IntegerType())\r\ndef to_celsius(temp):\r\n    if isinstance(temp, int):\r\n "

 

def count_lines(data):  

return len([line for line in data.split('\n') if line.strip() and not line.startswith('#')])

 

Error Message :

AttributeError: 'dict" object has no attribulte 'len'


Note: I have tried this with multiple text and binary files.  


I am working in a Winows environmet and using python 3.6

Web2py : Version2.18.5-stable+timestamp.2019.04.08.04.22.03


In summary :

I don't think the upload_file method is meant for binary data nor Windows style line returns in text files.

Is this working as designed in web2py on Windows ?  


Thanks in advance,

David



Reply all
Reply to author
Forward
Message has been deleted
0 new messages