Projet

Général

Profil

Bug #42672

{{form_option_...}} rendue comme "time.struct_time..."

Ajouté par Thomas Noël il y a presque 4 ans. Mis à jour il y a presque 4 ans.

Statut:
Fermé
Priorité:
Normal
Assigné à:
-
Version cible:
-
Début:
09 mai 2020
Echéance:
% réalisé:

0%

Temps estimé:
Patch proposed:
Oui
Planning:
Non

Description

Je pensais que c'était corrigé par #41853 mais on dirait que non.

Sur une action globale qui a une date de référence {{form_option_date_anonym}}, celle-ci étant de type date, on se retrouve avec une string "time.struct_time(...)" qui ne peut donc pas être vue comme une date par get_as_datetime.

Exception:
  type = '<class 'ValueError'>', value = 'time data 'time.struct_time(tm_year=2020, tm_mon=5, tm_mday=8, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=4, tm_yday=129, tm_isdst=-1)' does
not match format '%d/%m/%y''

Stack trace (most recent call first):
  File "/usr/lib/python3.5/_strptime.py", line 343, in _strptime
   341     if not found:
   342         raise ValueError("time data %r does not match format %r" %
>  343                          (data_string, format))
   344     if len(data_string) != found.end():
   345         raise ValueError("unconverted data remains: %s" %

  locals:
     arg = '%d/%m/%y'
     data_string = 'time.struct_time(tm_year=2020, tm_mon=5, tm_mday=8, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=4, tm_yday=129, tm_isdst=-1)'
     format = '%d/%m/%y'
     format_regex = re.compile('(?P<d>3[0-1]|[1-2]\\d|0[1-9]|[1-9]| [1-9])/(?P<m>1[0-2]|0[1-9]|[1-9])/(?P<y>\\d\\d)', re.IGNORECASE)
     found = None
     index = 1
     locale_time = <_strptime.LocaleTime object at 0x7fc4633dc588>

  File "/usr/lib/python3.5/_strptime.py", line 510, in _strptime_datetime
   508     """Return a class cls instance based on the input string and the
   509     format string.""" 
>  510     tt, fraction = _strptime(data_string, format)
   511     tzname, gmtoff = tt[-2:]
   512     args = tt[:6] + (fraction,)

  locals:
     cls = <class 'datetime.datetime'>
     data_string = 'time.struct_time(tm_year=2020, tm_mon=5, tm_mday=8, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=4, tm_yday=129, tm_isdst=-1)'
     format = '%d/%m/%y'

  File "/usr/lib/python3/dist-packages/wcs/qommon/misc.py", line 249, in get_as_datetime
   247         except ValueError as e:
   248             exception = e
>  249     raise exception
   250
   251

  locals:
     exception = ValueError("time data 'time.struct_time(tm_year=2020, tm_mon=5, tm_mday=8, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=4, tm_yday=129, tm_isdst=-1)' does not match
format '%d/%m/%y'",)
     format_string = '%d/%m/%y'
     formats = ['%d/%m/%Y %H:%M', '%d/%m/%Y', '%Y-%m-%d %H:%M', '%Y-%m-%d %H:%M:%S', '%Y-%m-%dT%H:%M:%S', '%Y-%m-%dT%H:%M:%SZ', '%y-%m-%d %H:%M', '%y-%m-%d %H:%M:%S', '%d/%m/%Y
%H:%M', '%d/%m/%Y %H:%M:%S', '%d/%m/%Y %Hh%M', '%d/%m/%y %H:%M', '%d/%m/%y %H:%M:%S', '%d/%m/%y %Hh%M', '%Y-%m-%d', '%y-%m-%d', '%d/%m/%Y', '%d/%m/%y']
     s = 'time.struct_time(tm_year=2020, tm_mon=5, tm_mday=8, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=4, tm_yday=129, tm_isdst=-1)'
     value = ['%d/%m/%Y', '%d/%m/%y']

  File "/usr/lib/python3/dist-packages/wcs/workflows.py", line 1224, in must_trigger
  1222                 anchor_date = get_as_datetime(anchor_date)
  1223             except ValueError:
> 1224                 get_publisher().notify_of_exception(sys.exc_info(), context='[TIMEOUTS]')
  1225                 anchor_date = None
  1226         elif anchor_date:

...

Fichiers


Demandes liées

Lié à w.c.s. - Development #41853: Affichage d'un champ date form_option dans l'historique d'une demande n'est pas formatéFermé18 avril 2020

Actions

Révisions associées

Révision 1a0642d4 (diff)
Ajouté par Frédéric Péters il y a presque 4 ans

misc: use lazy mode for global action expression date template (#42672)

Historique

#2

Mis à jour par Thomas Noël il y a presque 4 ans

  • Lié à Development #41853: Affichage d'un champ date form_option dans l'historique d'une demande n'est pas formaté ajouté
#3

Mis à jour par Thomas Noël il y a presque 4 ans

En première lecture ça pourrait être lié au fait qu'on est pas en mode lazy sur cette évaluation :

        ...
        elif self.anchor == 'template':
            variables = get_publisher().substitutions.get_context_variables()
            anchor_date = Template(self.anchor_template, autoescape=False).render(variables)
#5

Mis à jour par Frédéric Péters il y a presque 4 ans

Oui faudrait sans doute lazy là. (je pensais l'avoir systématisé pour les appels aux gabarits).

#6

Mis à jour par Frédéric Péters il y a presque 4 ans

(je pensais à #38332, mais il est venu après l'écriture du code utilisé ici pour la date)

#7

Mis à jour par Frédéric Péters il y a presque 4 ans

Voilà avec le test qui reproduit la trace de ce ticket.

#8

Mis à jour par Thomas Noël il y a presque 4 ans

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

Mis à jour par Frédéric Péters il y a presque 4 ans

  • Statut changé de Solution validée à Résolu (à déployer)
commit 1a0642d45da5735dbeb99f255959d7e38dfcaffc
Author: Frédéric Péters <fpeters@entrouvert.com>
Date:   Sat May 9 10:41:52 2020 +0200

    misc: use lazy mode for global action expression date template (#42672)
#10

Mis à jour par Frédéric Péters il y a presque 4 ans

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

Formats disponibles : Atom PDF