Greetings,

I asked the question here in title on StackOverflow 
<http://stackoverflow.com/questions/32226325/web2py-sqlform-update-or-insert-depending-on-record-existence-checked-at-callbac>
 
and it seems that the solution, that Richard 
<http://stackoverflow.com/users/2027027/richard> nicely brought to me/us, 
should 
work "as is", but also seem to have side effects in my environment so that 
I can't make it work properly.

So I came here, on his suggestion, in order to try to understand how it 
could work properly.

The big picture:

   - My application manages "objects" (say, celestial phenomena), sometimes 
   they have variants, and I'm on managing they occurrences.
   - I need to produce a very simple interface, in only one form on one 
   page (demanding customer requirement ^^).
   - Object occurrences are mainly defined by a reference id and an 
   associated file that can be uploaded later.
   - Uploading the file triggers a scheduler task that will process it and 
   will remove it form application and database once processed. (this part is 
   not mentioned in my post to StackOverflow because I didn't want to overload 
   it).

So I came to a model that partly looks like this:

db.define_table('t_object_occurence',
    Field('f_refid', type='string', label=T('Reference')),
    Field('f_object_id', db.t_object, label=T('Object')),
    Field('f_temp_file', type='upload', label=T('File'), autodelete=True)
    Field('f_temp_filename', type='string', readable=False, writable=False),

    Field('f_temp_file_processed', type='boolean', writable=True),

    #more fileds
)


Following Richard's solution, I have to put all of my checks and processing 
right in onvalidation_insert_or_update() but something goes wrong when it 
comes to build the uploaded file path: expression 

os.path.join(os.path.abspath('.'),'applications/'+request.application+
'/uploads/'+form.vars.f_temp_file)
raises a 

TypeError: cannot concatenate 'str' and 'instance' objects

whereas it just works like a charm when it is executed inside the 
controller, right after 

if form.process(dbio=False, 
onvalidation=onvalidation_insert_or_update).accepted:


(How) can I get the uploaded file name from inside 
onvalidation_insert_or_update()?


By the way, I'm not sure but it seems that there is no need to put a 
db.commit() inside this function. Is it correct?


Thank you,
Fred.

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to