Projet

Général

Profil

Bug #42960

Internal Server Error sur import d'un formulaire utiisant des fiches en source de données

Ajouté par Laurent Séguin il y a presque 4 ans. Mis à jour il y a presque 4 ans.

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

0%

Temps estimé:
Patch proposed:
Oui
Planning:
Non

Description

Lorsqu'on importe un formulaire utilisant en source de donnée une (ou des) fiches, on est renvoyé sur un « Internal Server Error »
Reproductible avec le formulaire en PJ


Fichiers

Révisions associées

Révision 2f6e7a35 (diff)
Ajouté par Thomas Noël il y a presque 4 ans

data_sources: return an empty list for an unknown carddef (#42960)

Historique

#1

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

L'import se fait mais c'est le preview du formulaire qui explose.

Exception:
  type = '<class 'KeyError'>', value = ''

Stack trace (most recent call first):
  File "/home/thomas/dev/publik/src/wcs/wcs/qommon/storage.py", line 469, in get_filename
   467             if ignore_errors:
   468                 return None
>  469             raise KeyError()
   470         except ImportError as e:
   471             if ignore_errors:

  locals: 
     cls = <class 'wcs.carddef.CardDef'>
     filename = '/var/lib/wcs/wcs.dev.publik.love/carddefs-url_name/agendas-lieux'
     ignore_errors = False
     ignore_migration = False
     kwargs = {}

  File "/home/thomas/dev/publik/src/wcs/wcs/qommon/storage.py", line 426, in get_on_index
   424         filename = os.path.join(index_dir, str(fix_key(id)))
   425         return cls.get_filename(filename, ignore_errors=ignore_errors,
>  426                 ignore_migration=ignore_migration)
   427 
   428     @classmethod

  locals: 
     cls = <class 'wcs.carddef.CardDef'>
     filename = '/var/lib/wcs/wcs.dev.publik.love/carddefs-url_name/agendas-lieux'
     id = 'agendas-lieux'
     ignore_errors = False
     ignore_migration = False
     index = 'url_name'
     index_dir = '/var/lib/wcs/wcs.dev.publik.love/carddefs-url_name'
     objects_dir = '/var/lib/wcs/wcs.dev.publik.love/carddefs'

  File "/home/thomas/dev/publik/src/wcs/wcs/formdef.py", line 524, in get_by_urlname
   522     @classmethod
   523     def get_by_urlname(cls, url_name, ignore_migration=False):
>  524         return cls.get_on_index(url_name, 'url_name', ignore_migration=ignore_migration)
   525 
   526     def get_url(self, backoffice=False, preview=False):

  locals: 
     cls = <class 'wcs.carddef.CardDef'>
     ignore_migration = False
     url_name = 'agendas-lieux'

  File "/home/thomas/dev/publik/src/wcs/wcs/data_sources.py", line 152, in get_structured_items
   150         # cards
   151         from wcs.carddef import CardDef
>  152         carddef = CardDef.get_by_urlname(data_source['type'][8:])
   153         items = [x.get_data_source_structured_item()
   154                  for x in carddef.data_class().select()

  locals: 
     CardDef = <class 'wcs.carddef.CardDef'>
     cache_duration = 0
     data_source = {'type': 'carddef:agendas-lieux', 'value': '[{"id":"retrait-masques-alpha", "text":"Nom du lieu de retrait, accompagné de l\'adresse de celui-ci"}]'}
     mode = None

  File "/home/thomas/dev/publik/src/wcs/wcs/data_sources.py", line 107, in get_items
   105 
   106 def get_items(data_source, include_disabled=False, mode=None):
>  107     structured_items = get_structured_items(data_source, mode=mode)
   108     tupled_items = []
   109     for item in structured_items:

  locals: 
     data_source = {'type': 'carddef:agendas-lieux', 'value': '[{"id":"retrait-masques-alpha", "text":"Nom du lieu de retrait, accompagné de l\'adresse de celui-ci"}]'}
     include_disabled = False
     mode = None

  File "/home/thomas/dev/publik/src/wcs/wcs/fields.py", line 1466, in perform_more_widget_changes
  1464         elif self.data_source:
  1465             items = data_sources.get_items(self.data_source,
> 1466                     include_disabled=self.display_disabled_items)
  1467             kwargs['options'] = [x[:3] for x in items if not x[-1].get('disabled')]
  1468             kwargs['options_with_attributes'] = items[:]

  locals: 
     data_source = <NamedDataSource None id:None>
     display_mode = 'list'
     edit = True
     form = <wcs.qommon.form.Form object at 0x7f45b3e02290>
     kwargs = {'required': True}
     self = <ItemField 23 'Lieu de retrait'>

  File "/home/thomas/dev/publik/src/wcs/wcs/fields.py", line 505, in add_to_form
   503             if hasattr(self, k):
   504                 kwargs[k] = getattr(self, k)
>  505         self.perform_more_widget_changes(form, kwargs)
   506         if self.hint and self.hint.startswith('<'):
   507             hint = htmltext(self.hint)

  locals: 
     form = <wcs.qommon.form.Form object at 0x7f45b3e02290>
     kwargs = {'required': True}
     self = <ItemField 23 'Lieu de retrait'>
     value = None

  File "/home/thomas/dev/publik/src/wcs/wcs/admin/forms.py", line 890, in get_preview
   888             field.id = i
   889             if hasattr(field, str('add_to_form')):
>  890                 field.add_to_form(form)
   891             else:
   892                 if field.key == 'page':

  locals: 
     field = <ItemField 23 'Lieu de retrait'>
     form = <wcs.qommon.form.Form object at 0x7f45b3e02290>
     i = 23
     on_page = 3
     self = <wcs.admin.forms.FormDefPage object at 0x7f45b3ce7fd0>

  File "/home/thomas/dev/publik/src/wcs/wcs/admin/forms.py", line 586, in _q_index
   584         r += htmltext('<h3 class="clear">%s <span class="change">(<a href="fields/">%s</a>)</span></h3>') % (
   585                         _('Fields'), _('edit'))
>  586         r += self.get_preview()
   587         r += htmltext('</div>')
   588         return r.getvalue()

  locals: 
     add_option_line = <function FormDefPage._q_index.<locals>.add_option_line at 0x7f45b3ce0c20>
     digest_template_status = 'Personnalisé'
     online_status = 'Désactivée'
     r = <TemplateIO object at 0x7f45b3e3ae90>
     role_id = None
     role_label = '-'
     self = <wcs.admin.forms.FormDefPage object at 0x7f45b3ce7fd0>
     warning_class = ''
     wf_role_id = '_receiver'
     wf_role_label = 'Destinataire'
     workflow_roles = [('_receiver', 'Destinataire')]
...
#2

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

  • Assigné à mis à Thomas Noël
#3

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

#4

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

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

(ça serait sans doute utile de remonter l'info comme quoi il manque une fiche au moment de l'import)

#5

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

  • Statut changé de Solution validée à Résolu (à déployer)
commit 2f6e7a3597875e3b48027d56079feb9260fd4989
Author: Thomas NOEL <tnoel@entrouvert.com>
Date:   Fri May 15 16:02:56 2020 +0200

    data_sources: return an empty list for an unknown carddef (#42960)

(et #42974 pour voir comment refuser ce genre d'import)

#6

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