I found a work around to solve this problem I added these 3 lines after form accepted
if request.env.web2py_runtime_gae: request.vars.file.file.seek(0) form.vars.file_blob = request.vars.file.file.read() Cause file_blob was None, I just set it. This thread was helpful. https://groups.google.com/forum/?fromgroups=#!search/%5Bweb2py%5D$20Re:$20Uploading$20Excel$20and$20reading$20from$20it/web2py/3wKcHVPBFI0/IobcR5OGcu8J 2012년 8월 21일 화요일 오후 2시 13분 37초 UTC+9, JungHyun Kim 님의 말: > > > I opend the ticket. > > Issue 948 > <http://code.google.com/p/web2py/issues/detail?id=948>:SQLFORM.factory > + Multiple Tables + Upload Field + GAE Blob Problem > Thank you Massimo. > > 2012년 8월 21일 화요일 오후 12시 25분 57초 UTC+9, Massimo Di Pierro 님의 말: >> >> Please open a ticket about this. >> >> On Monday, 20 August 2012 11:49:14 UTC-5, JungHyun Kim wrote: >>> >>> Hello! >>> >>> I have a problem with upload field. >>> >>> I tried to upload a file through one form with two tables using >>> SQLFORM.factory. >>> It worked OK on web2py rocket server. But with GAE server (both local >>> test server and real GAE server), I can't upload files. >>> The problem is blob is None after uploaded. >>> >>> I defined two tables. >>> >>> >>> >>> db.define_table('mibmessage', >>> Field('user',db.auth_user,writable=False,readable= >>> False,default=auth.user_id,), >>> Field('message','text',notnull=True, >>> widget = lambda field, value: SQLFORM. >>> widgets.text.widget(field, value, _class='my-string')), >>> Field('attached_files','list:reference >>> attached_file', writable=False, default=[], readable=False), >>> ) >>> >>> db.define_table('attached_file', >>> Field('file','upload'), >>> Field('original_filename', writable=False, notnull= >>> False), >>> Field('mibmessage',db.mibmessage), >>> ) >>> >>> >>> >>> And in controller, I saved them. >>> >>> # Make a form >>> form = SQLFORM.factory(db.mibmessage, db.attached_file, table_name= >>> 'attached_file') >>> >>> # Save New Message >>> if form.process().accepted: >>> try: >>> # Insert a message >>> message_id = db.mibmessage.insert(**db.mibmessage. >>> _filter_fields(form.vars)) >>> form.vars.mibmessage=message_id >>> >>> if form.vars.file != '': >>> form.vars.original_filename = request.vars.file.filename >>> # Insert an attached file >>> image_file_id = db.attached_file.insert(**db. >>> attached_file._filter_fields(form.vars)) >>> >>> # The message has a list of attached files >>> db.mibmessage[message_id].update_record(attached_files=[ >>> image_file_id]) >>> db.commit() >>> >>> except Exception: >>> db.rollback() >>> >>> >>> After uploaded, both rows are created. But 'file_blob' field of the >>> 'attached_file' is None. >>> >>> If I upload an file using SQLFORM with single table (attached_file), it >>> is OK. >>> >>> Did I use SQLFORM.factory wrong? >>> >>> I read this thread ( >>> https://groups.google.com/forum/?fromgroups#!searchin/web2py/SQLFORM.factory$20one$20form$20multiple$20tables$20blob/web2py/O6D1J8h_MNA/lmFbEF1XzWcJ%5B1-25%5D), >>> >>> but I couldn't understand it. >>> >>> >>> >>> >>> >>> --