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. 





-- 



Reply via email to