Projet

Général

Profil

Bug #10862

champs date => crash ''str' object has no attribute 'timetuple''

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

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

0%

Temps estimé:
Patch proposed:
Non
Planning:
Non

Description

Sur un formulaire avec un champ date sans particularité

Exception:
  type = '<type 'exceptions.AttributeError'>', value = ''str' object has no attribute 'timetuple''

Stack trace (most recent call first):
  File "/usr/lib/python2.7/dist-packages/wcs/sql.py", line 955, in _row2obdata
   953                     value = d
   954                 if sql_type == 'date':
>  955                     value = value.timetuple()
   956                 elif sql_type == 'bytea':
   957                     value = cPickle.loads(str(value))

  locals:
     sql_type = 'date'
     formdef = <FormDef 'Inscription au registre des personnes fragiles' id:32>
     i = 31
     obdata = {'11': 'SDFGS', '10': 'SDFGS', '13': 'SDFG', '12': 'SDFG', '15': None, '14': 'SDFGSD', '17': 'Parent', '16': None, '17_display': 'Parent', '9': 'sdfG', '20': '
SQDF', '21': 'QSDF'}
     value = '2010-01-27 00:00:00'
     field = <wcs.fields.DateField object at 0x429b5d0>
     cls = <class 'wcs.formdef.Inscription-Au-Registre-Des-Personnes-Fragiles'>
     row = (7, None, None, datetime.datetime(2016, 5, 9, 10, 55, 26), 'draft', '2', None, <read-only buffer for 0x2c7b6d0, size 2, offset 0 at 0x3c9bdb0>, '32-7', None, None
, ['_submitter'], [], 'KCTTNFRK', False, None, None, 0, 'sdfG', 'SDFGS', 'SDFGS', 'SDFG', 'SDFG', 'SDFGSD', None, None, 'Parent', 'Parent', <read-only buffer for 0x2c7bdd0,
size 2, offset 0 at 0x3c9bb30>, 'SQDF', 'QSDF', '2010-01-27 00:00:00', 'SDQSDF', 'QSDFQS', 'QSDF', None, None, None, <read-only buffer for 0x2c7ba30, size 2, offset 0 at
0x3c9b6b0>, None, None, <read-only buffer for 0x2c7ba70, size 2, offset 0 at 0x3c9bd30>, None, None, None, <read-only buffer for 0x2c7b350, size 2, offset 0 at 0x3c9bd70>,
None, None, <read-only buffer for 0x2c7b950, size 2, offset 0 at 0x3c9b030>, None)

  File "/usr/lib/python2.7/dist-packages/wcs/sql.py", line 1272, in _row2ob
  1270                                      'lat': float(m.group(2))}
  1271
> 1272         o.data = cls._row2obdata(row, cls._formdef)
  1273         return o
  1274


Fichiers

inscription-au-registre-des-personnes-fragiles.wcs (10,5 ko) inscription-au-registre-des-personnes-fragiles.wcs Thomas Noël, 09 mai 2016 11:38
32.pickle (8,93 ko) 32.pickle Thomas Noël, 11 mai 2016 14:03

Historique

#1

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

Il y avait un champ date (optionnelle, dans le passe) sur le formulaire ci-joint. Il a été supprimé et tout va bien.

J'ai repris le formulaire, tenté de rajouter une date avec les mêmes contraintes, sans parvenir à reproduire le bogue.

wcs 1.42

#2

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

PATH_INFO       '/sante-social/inscription-au-registre-des-personnes-fragiles/autosave'
#3

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

Frédéric Péters a écrit :

[...]

Ouaip... mais la trace que j'ai écrite dans le ticlet s'affichait à l'écran, lors du POST de la page.

#4

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

Formulaire extrait des backups avant modification (8 mai 08h00)

#5

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

Intéressant on garde les logs postgresql détaillés, on va du coup pouvoir trouver les CREATE et ALTER TABLE. (trop galère à faire avc un mauvais wifi dans le train, par contre)

#6

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

log postgresql:

2016-05-09 10:26:38.861 CEST LOG:  statement: UPDATE formdata_32_inscription_au_registre_des_pe SET concerned_roles_array = ARRAY['_submitter'],
 f9 = 'TEST', tracking_code = 'XJTPXRBT', f31_structured = '\x4e2e'::bytea, f17_structured = '\x4e2e'::bytea, workflow_roles_array = NULL, user_
id = NULL, f14 = '03 83 39 03 53', f17_display = 'Parent', f31 = NULL, submission_context = NULL, f23 = NULL, f22 = '1939-06-30T00:00:00'::times
tamp, f21 = 'Josette', f20 = 'TEST', receipt_time = ('2016-05-09T10:26:38'::timestamp), user_hash = NULL, id_display = '32-2', f24 = NULL, f29 =
 NULL, f28 = NULL, f28_structured = '\x4e2e'::bytea, f29_display = NULL, actions_roles_array = '{}', f26 = NULL, status = 'draft', f31_display =
 NULL, f25 = NULL, f11 = '3 rue du Cheval', workflow_roles = NULL, f13 = 'NANCY', workflow_data = '\x4e2e'::bytea, f32_structured = '\x4e2e'::by
tea, f32_display = NULL, f28_display = NULL, f17 = 'Parent', f30 = NULL, f29_structured = '\x4e2e'::bytea, f32 = NULL, f33 = NULL, anonymised = 
NULL, f12 = '54000', backoffice_submission = false, f10 = 'Rémi', criticality_level = 0, f16 = 'remitest@yahoo.fr', submission_channel = NULL, p
age_no = 2, f15 = '06 89 54 72 65' WHERE id = 2 RETURNING id
[...]
2016-05-09 10:26:44.065 CEST LOG:  statement: SELECT id, user_id, user_hash, receipt_time, status, page_no, anonymised, workflow_data, id_display, workflow_roles, workflow_roles_array, concerned_roles_array, actions_roles_array, tracking_code, backoffice_submission, submission_context, submission_channel, criticality_level
                                          , 
                                          f9, f10, f11, f12, f13, f14, f15, f16, f17, f17_display, f17_structured, f20, f21, f22, f23, f24, f25, f26, f28, f28_display, f28_structured, f29, f29_display, f29_structured, f30, f31, f31_display, f31_structured, f32, f32_display, f32_structured, f33
                                     FROM formdata_32_inscription_au_registre_des_pe
                                    WHERE id = '2'

log wcs:

2016-05-09 10:26:38,913 INFO 62.244.71.158 298667097e37ef96 /sante-social/inscription-au-registre-des-personnes-fragiles/autosave unlogged - for
m Inscription au registre des personnes fragiles - saving draft (id: 2)
2016-05-09 10:26:44,347 ERROR 62.244.71.158 298667097e37ef96 /sante-social/inscription-au-registre-des-personnes-fragiles/autosave unlogged - internal server error

On a donc bien un timestamp inséré dans la base et juste derrière, quand on récupère la ligne, ce qui se trouve dans le retour du fetchrow, c'est une chaine "2010-01-27 00:00:00", comme si l'adapteur de type de psycopg2 n'avait pas fait son boulot. (mais je ne trouve pas de référence à un bug de ce type, il y a quantité de tests dans psycopg2 et par une lecture du code je ne vois pas comment ça pourrait arriver).

#7

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

  • Statut changé de Nouveau à Fermé

Plus jamais arrivé.

Formats disponibles : Atom PDF