I don't understand too, I do not see any connection, but I'm sure... Without "print request" command the file uploaded has 0 bytes. With "print request" command the file uploaded has the correct size...
On Thu, Jul 25, 2013 at 10:04 AM, Massimo Di Pierro < [email protected]> wrote: > Are you sure about your point 2. I do not see how adding a print statement > can affect the working (or not working) of this form. > > > On Tuesday, 23 July 2013 21:18:07 UTC-5, __pyslan__ wrote: >> >> Hello everybody. >> >> >> I'm trying upload files with SQLFORM.grid. >> >> Model: >> >> FilesUploaded = db.define_table('files_**uploaded', >> Field('name', notnull=True, label=T("Name")), >> Field('file_name', 'upload', notnull=False, label=T("File")), >> Field('owner_group', 'reference auth_group', notnull=True, >> label=T("Owner Group")), >> Field('creation', 'datetime', notnull=True, >> default=datetime.datetime.now(**), label=T("Creation")), >> format='%(name)s') >> >> >> Constraints: >> >> FilesUploaded.owner_group.comp**ute = lambda row: >> auth.user_groups.keys()[0]FilesUploaded.owner_group.read**able = >> FalseFilesUploaded.owner_group.writ**able = False >> FilesUploaded.creation.writabl**e = FalseFilesUploaded.file_name.requir**es >> = IS_LENGTH(maxsize=(1024*(1024***5)), error_message=T("Send files with a >> maximum size of") + " 5GB.") >> >> >> def upload_validation(form): >> sent_file = request.vars.file_name.file >> file_name = request.vars.file_name.filenam**e >> extension_file = file_name.split('.')[-1] >> >> if extension_file == 'csv': >> import csv >> file_lines = list(csv.reader(sent_file, delimiter=',', >> quoting=csv.QUOTE_NONE)) >> elif extension_file == 'txt': >> file_lines = list(sent_file.readlines()) >> else: >> form.errors.file_name = T("The file types supported are .csv or >> .txt") >> return False >> >> max_lines = 100000 >> >> if len(lines) > max_lines: >> form.errors.file_name = T("Maximum quantity per upload is %(qty)s >> lines.") % dict(qty = max_lines) >> return False >> >> Controller: >> >> form=SQLFORM.grid(query, csv=False, fields=fields, links=links, >> user_signature=True, onvalidation=upload_validation**) >> >> >> >> 1 -> The file size is 0 bytes after upload. >> 2 -> But, if I put the command "print request" on the last line of >> upload_validation function, works fine. >> >> >> If anyone can help me, I appreciate! >> >> >> __pyslan__ >> >> >> -- > > --- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

