Project

General

Profile

Development #13379

Renvoyer 404 sur /api/formdefs/xxx/ où xx est inconnu

Added by Benjamin Dauvergne about 6 years ago. Updated almost 6 years ago.

Status:
Fermé
Priority:
Normal
Assignee:
-
Target version:
Start date:
30 September 2016
Due date:
% Done:

0%

Estimated time:
Patch proposed:
Yes
Planning:

Description

Exception:
  type = '<type 'exceptions.KeyError'>', value = ''

Stack trace (most recent call first):
  File "/usr/lib/python2.7/dist-packages/wcs/qommon/storage.py", line 370, in get_filename
   368             if ignore_errors:
   369                 return None
>  370             raise KeyError()
   371         except ImportError as e:
   372             if ignore_errors:

  locals: 
     ignore_errors = False
     ignore_migration = False
     cls = <class 'wcs.formdef.FormDef'>
     filename = '/var/lib/wcs-au-quotidien/montpellier.eservices.montpellier3m.fr/formdefs-url_name/incident-sur-le-reseau-d-eaux-usee'

  File "/usr/lib/python2.7/dist-packages/wcs/qommon/storage.py", line 330, in get_on_index
   328         filename = os.path.join(index_dir, str(fix_key(id)))
   329         return cls.get_filename(filename, ignore_errors=ignore_errors,
>  330                 ignore_migration=ignore_migration)
   331 
   332     @classmethod

  locals: 
     index_dir = '/var/lib/wcs-au-quotidien/montpellier.eservices.montpellier3m.fr/formdefs-url_name'
     ignore_migration = False
     index = 'url_name'
     filename = '/var/lib/wcs-au-quotidien/montpellier.eservices.montpellier3m.fr/formdefs-url_name/incident-sur-le-reseau-d-eaux-usee'
     objects_dir = '/var/lib/wcs-au-quotidien/montpellier.eservices.montpellier3m.fr/formdefs'
     ignore_errors = False
     id = 'incident-sur-le-reseau-d-eaux-usee'
     cls = <class 'wcs.formdef.FormDef'>

  File "/usr/lib/python2.7/dist-packages/wcs/formdef.py", line 409, in get_by_urlname
   407     @classmethod
   408     def get_by_urlname(cls, url_name, ignore_migration=False):
>  409         return cls.get_on_index(url_name, 'url_name', ignore_migration=ignore_migration)
   410 
   411     def get_url(self, backoffice=False, preview=False):

  locals: 
     url_name = 'incident-sur-le-reseau-d-eaux-usee'
     ignore_migration = False
     cls = <class 'wcs.formdef.FormDef'>

  File "/usr/lib/python2.7/dist-packages/wcs/api.py", line 344, in _q_lookup
   342 
   343     def _q_lookup(self, component):
>  344         return ApiFormdefDirectory(FormDef.get_by_urlname(component))
   345 
   346 

  locals: 
     self = <wcs.api.ApiFormdefsDirectory object at 0x7fb94129cb50>
     component = 'incident-sur-le-reseau-d-eaux-usee'

Files

Associated revisions

Revision 7fa3757a (diff)
Added by Benjamin Dauvergne almost 6 years ago

api: return 404 on access to an unknown formdef (#13379)

History

#2

Updated by Frédéric Péters (de retour le 10/10) almost 6 years ago

  • Status changed from Nouveau to En cours

Ce n'est pas uniforme pour le moment mais je préfère la forme courte, try: return ApiFormdefDirectory(FormDef.get_by_urlname(component)) except KeyError: ..., ou alors faire sauter le else: et mettre le return hors du bloc.

Et ajouter un test bidon qui tape au mauvais endroit.

#3

Updated by Benjamin Dauvergne almost 6 years ago

Je préférerai largement ne pas inutilement cacher au passage une KeyError dans le code de ApiFormdefDirectory, je ne vois vraiment pas l'intérêt de gagner une ligne ici; je veux bien par contre virer le else par souci de style.

#4

Updated by Frédéric Péters (de retour le 10/10) almost 6 years ago

ok pour juste virer le else.

#6

Updated by Frédéric Péters (de retour le 10/10) almost 6 years ago

  • Status changed from En cours to Résolu (à déployer)
commit 7fa3757a2cbb0f6f62dcdae5c00f9dbbbffafc4c
Author: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Date:   Fri Sep 30 13:54:55 2016 +0200

    api: return 404 on access to an unknown formdef (#13379)
#7

Updated by Frédéric Péters (de retour le 10/10) almost 6 years ago

  • Target version set to v1.61
#8

Updated by Frédéric Péters (de retour le 10/10) almost 6 years ago

  • Status changed from Résolu (à déployer) to Fermé

Also available in: Atom PDF