can onvalidation set upload file field?
i was complaining that form.vars was empty.
It is if the controller does not return the form to the view
So i return the form and away with my quest.
Now, in onvalidation i set the field with the upload file.
I have to becaue i have a different upload button that goes online to get a file.
Its working but the image file i set goes as a txt file to the database, why
here my code:
(I use PIL module)
if trabalhador_form.process(onvalidation=attach_image_to_record).accepted:
def attach_image_to_record(form):
response=requests.get(form.vars.fp_url)
img=Image.open(StringIO(response.content))
img.save('foto1231.jpg','JPEG')
temp=open('foto1231.jpg','rb')
photo=db.trabalhador.foto.store(temp,'foto.jpg')
print photo # echoes something like "trabalhador.foto.989708787087078.9823492034.jpg
form.vars.photo=photo # here is where someting goes wrong....
This is very important for me ,
can anyone explain why a jpg is inserted as a txt? how to force jpg ?
Thank you
António