Bug #13777
modification des champs de traitement: crash sur fichier uploadé
Début:
27 octobre 2016
Echéance:
% réalisé:
0%
Temps estimé:
Patch proposed:
Oui
Planning:
Description
Contexte:
- un formulaire de workflow (visite) avec un champs fichier (photo1)
- puis une action "modification des champs de traitement" qui utilise =visite_var_photo1_raw
Mais ça ne marche pas, le champs de traitement reste vide.
La trace pourtant fait mention d'un objet "<PicklableUpload at 793d878: facture-elec.png>" :
Exception: type = '<type 'exceptions.ValueError'>', value = 'invalid data for file type (<PicklableUpload at 793d878: facture-elec.png>)' Stack trace (most recent call first): File "/usr/lib/python2.7/dist-packages/wcs/wf/backoffice_fields.py", line 108, in get_file_value 106 return upload 107 > 108 raise ValueError('invalid data for file type (%r)' % new_value) 109 110 def perform(self, formdata): locals: new_value = <PicklableUpload at 793d878: facture-elec.png> self = <wcs.wf.backoffice_fields.SetBackofficeFieldsWorkflowStatusItem object at 0x62e3250> File "/usr/lib/python2.7/dist-packages/wcs/wf/backoffice_fields.py", line 130, in perform 128 new_value = self.get_file_value(new_value) 129 except ValueError: > 130 get_publisher().notify_of_exception(sys.exc_info()) 131 continue 132 locals: self = <wcs.wf.backoffice_fields.SetBackofficeFieldsWorkflowStatusItem object at 0x62e3250> field = {'field_id': 'bo16', 'value': '=visite_var_photo1_raw'} x = <wcs.fields.TextField object at 0x7b91710> new_value = <PicklableUpload at 793d878: facture-elec.png> formdef_field = <wcs.fields.FileField object at 0x7b91150> formdata = <Demande-De-Proximite 'Demande de proximit\xc3\xa9 - n\xc2\xb01-15' id:15>
Pourtant dans le code :
def get_file_value(self, new_value): if isinstance(new_value, PicklableUpload): return new_value ... raise ValueError('invalid data for file type (%r)' % new_value)
donc le isinstance ne passe pas... peut-être confusion entre qommon.form.PicklableUpload et wcs.qommon.form.PicklableUpload ? (souvenir d'un pb passé, #11000)
Fichiers
Révisions associées
Historique
Mis à jour par Thomas Noël il y a plus de 7 ans
Ca crache effectivement quand
--- a/tests/test_workflows.py +++ b/tests/test_workflows.py @@ -1922,7 +1922,8 @@ def test_set_backoffice_field_file(pub): formdef.workflow_id = wf.id formdef.store() - upload = PicklableUpload('test.jpeg', 'image/jpeg') + from wcs.qommon.form import PicklableUpload as PicklableUpload2 + upload = PicklableUpload2('test.jpeg', 'image/jpeg') upload.receive([open(os.path.join(os.path.dirname(__file__), 'image-with-gps-data.jpeg')).read()]) formdata = formdef.data_class()()
Mis à jour par Thomas Noël il y a plus de 7 ans
- Fichier 0001-workflows-check-file-type-with-hasattr-for-backoffic.patch 0001-workflows-check-file-type-with-hasattr-for-backoffic.patch ajouté
- Statut changé de Nouveau à En cours
- Assigné à mis à Thomas Noël
- Patch proposed changé de Non à Oui
Bon, j'ai pas testé "en vrai", cependant.
Mis à jour par Thomas Noël il y a plus de 7 ans
Testé sur la recette, et c'était bien le soucis. Relecteurs bienvenus.
Mis à jour par Frédéric Péters il y a plus de 7 ans
/Same as/Similar to/.
Je virerais le isinstance().
Mis à jour par Thomas Noël il y a plus de 7 ans
Mis à jour par Thomas Noël il y a plus de 7 ans
- Statut changé de En cours à Résolu (à déployer)
commit 7e91ff8ee98ac23aad8f91ece3bf9b35cc55ac63 Author: Thomas NOEL <tnoel@entrouvert.com> Date: Thu Oct 27 16:55:53 2016 +0200 workflows: check file type with hasattr() for backoffice fields (#13777) PicklableUpload may exist in different namespaces, and then there's also an independant UploadedFile class; just check if will duck like a file. Similar to #11000 (commit 2adbdc1720)
workflows: check file type with hasattr() for backoffice fields (#13777)
PicklableUpload may exist in different namespaces, and then there's also
an independant UploadedFile class; just check if will duck like a file.
Similar to #11000 (commit 2adbdc1720)