Hello,

I am looking for support to interface 2 web2py applications via
@service.soap

app1: is running on portable device, has a table with a field
(Field('f_assest', type 'upload')), used to store files such as jpeg, zip
or pdf files. This app1 can run on stand alone, not connected device, but,
when the user decides so, should send some info to app2. The files stored
in le 'uploads' directory of app1 in are small (typically 0.5 MB).

app2: running on a central server (@ getup).

For interfacing app1 = app2, I try to use the @service.soap.

And there, I am facing some problems on the client side, and others on the
server side.

*On the client side (app1)*:

- I cannot find a correct and efficient way(not taking too much time...) to
integrate my 'f_assest' field in the dictionary structure, and I am not
sure about the message coding requirements.

Assuming the value of the file name is the variable my_f_assest_value, here
is what I do :

path = os.path.join(request.folder,'uploads',my_f_assest_value)
myfile = open(path, "rb")
myline['x_file_content']= unicode(myfile.read())
myfile.close()

*On the server side (app2)*:

I want to integrate myline['x_file_content'] in a table (my table name =
db.t_txp_expense_line)

First I create the record in my table with the other attributes transferred
from my client correctly beside ['x_file_content']
            myline_id = db.t_txp_expense_line.insert(
            f_expense = myexpense_id,
            is_active = 'T',
            created_on = request.now,
            modified_on = request.now,
            created_by = myuser_id,
            modified_by = myuser_id,
            f_date = mydate)

This creation works fine... Initially, I tried to merge the next step with
this one, but everything was blocking...

In the next step, I check if there is something in the variable
['x_file_content'], and if so, I update the record just created before...
To make it easier for my first test, I imposed the filename to
'myfilename', which is up to now, not existing in my uploads directory.
The following instructions DO NOT WORK... The file is not uploaded, and the
record not updated. It seems to loop indefinitely...

            if (['x_file_content']) : # Is there any file to upload?
               db(db.t_txp_expense_line.id == myline_id).update(f_assest =
db.t_txp_expense_line.f_assest.store(cStringIO.StringIO(str(['x_file_content'])),
'myfilename'))

I am not at all an it expert. So, I confess I am struggling with *streaming*
and *coding/uncoding* features which might also be critical to store data
into the dictionary structure on the client side, and to send them safely
from the client to the server...

Thanks in advance for any advise / support.

Serge

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to