Projet

Général

Profil

Bug #70377

trace sur workflow qui fait une création de demande/fiche et le workflow de la demande/fiche qui supprime celle-ci

Ajouté par Frédéric Péters il y a plus d'un an. Mis à jour il y a plus d'un an.

Statut:
Fermé
Priorité:
Normal
Assigné à:
Version cible:
-
Début:
17 octobre 2022
Echéance:
% réalisé:

0%

Temps estimé:
Patch proposed:
Oui
Planning:
Non

Description

On crée la demande/fiche, puis on lance le workflow, puis on enregistre ce que le workflow n'a éventuellement pas enregistré,

  File "/usr/lib/python3/dist-packages/wcs/wf/create_formdata.py", line 602, in perform
   600                     code.formdata = new_formdata  # this will .store() the code
   601                 new_formdata.perform_workflow(event=('workflow-created', formdata.get_display_id()))
>  602                 new_formdata.store()

mais si le workflow a supprimé la demande/fiche, le .store() va échouer : il y aura un ._evolution dont les éléments vont être cherchés et ça va se finir en :

Exception:
  type = '<class 'TypeError'>', value = ''NoneType' object is not subscriptable'

Stack trace (most recent call first):
  File "/usr/lib/python3/dist-packages/wcs/sql.py", line 2795, in store
  2793                     sql_dict['parts'] = None
  2794                 cur.execute(sql_statement, sql_dict)
> 2795                 evo._sql_id = cur.fetchone()[0]
  2796
...

à la lecture j'aurais aussi peur que ça ne réenregistre la demande/fiche parce que ça fait :

            sql_statement = '''UPDATE %s SET %s WHERE %s RETURNING id''' % (
...
            cur.execute(sql_statement, sql_dict)
            if cur.fetchone() is None:
                if len(where) > 1: # on n'entre pas là-dedans
                    # abort if nothing was modified and there were extra where clauses
                    raise NothingToUpdate()
...
                sql_statement = '''INSERT INTO %s (%s) VALUES (%s) RETURNING id''' % (

je pense qu'on peut profiter du if len(where) ici pour :

@@ -639,7 +639,10 @@ class CreateFormdataWorkflowStatusItem(WorkflowStatusItem):
                 if formdef.enable_tracking_codes:
                     code.formdata = new_formdata  # this will .store() the code
                 new_formdata.perform_workflow(event=('workflow-created', formdata.get_display_id()))
-                new_formdata.store()
+                try:
+                    new_formdata.store(where=[Equal('id', new_formdata.id)])
+                except NothingToUpdate:
+                    pass

(pas testé et cerveau lavé par une réunion trop longue)


Fichiers


Demandes liées

Lié à w.c.s. - Bug #49599: TypeError: 'NoneType' object is not subscriptableFermé18 décembre 2020

Actions

Révisions associées

Révision 88bea4bb (diff)
Ajouté par Frédéric Péters il y a plus d'un an

workflows: do not save created card/form if workflow removed it (#70377)

Historique

#2

Mis à jour par Frédéric Péters il y a plus d'un an

Ça ne fonctionne pas parce que c'est même plus simple : à la suppression le new_formdata.id est mis à None, on peut juste regarder ça.

#3

Mis à jour par Thomas Noël il y a plus d'un an

  • Statut changé de Solution proposée à Solution validée

Good catch.

#4

Mis à jour par Frédéric Péters il y a plus d'un an

  • Statut changé de Solution validée à Résolu (à déployer)
commit 88bea4bb65db9f3e8eab5b44d007032439f5a2c9
Author: Frédéric Péters <fpeters@entrouvert.com>
Date:   Mon Oct 17 20:01:09 2022 +0200

    workflows: do not save created card/form if workflow removed it (#70377)
#5

Mis à jour par Transition automatique il y a plus d'un an

  • Statut changé de Résolu (à déployer) à Solution déployée
#6

Mis à jour par Transition automatique il y a plus d'un an

Automatic expiration

#7

Mis à jour par Frédéric Péters il y a 5 mois

  • Lié à Bug #49599: TypeError: 'NoneType' object is not subscriptable ajouté

Formats disponibles : Atom PDF