misc: extend |getlist on blocks, for compatibility names (#89777) #1423
No reviewers
Labels
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: entrouvert/wcs#1423
Loading…
Reference in New Issue
No description provided.
Delete Branch "wip/89777-getlist-block-relations"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
3612b0df16
to804d5c00fc
804d5c00fc
toda1be3fd7f
WIP: getlist on blocks, with compatibility names (89663 à la base)to WIP: misc: extend |getlist on blocks, for compatibility names (#89777)WIP: misc: extend |getlist on blocks, for compatibility names (#89777)to misc: extend |getlist on blocks, for compatibility names (#89777)@ -1905,2 +1905,3 @@
else:
raise AttributeError('No such attribute %r' % key)
value = [CompatibilityNamesDict({'X': x}).get(f'X_{key}') for x in self]
if all(x is None for x in value):
Dans quel cas on aurait CompatibilityNamesDict({'X': x})[f'X_{key}'] qui lèverait KeyError pour un x mais pas tous ? Si ça n'arrive pas ça me parait plus sûr de juste faire
Aussi all(x is None for x in value) est vrai si value est vide et il y a le cas où card_live_var_plop vaut effectivement None qu'il ne faudrait pas forcément empêcher.
da1be3fd7f
to3d0bd02311
@ -5158,0 +5196,4 @@
# add empty data
carddata = carddef.data_class()()
carddata.data = {}
Test étendu avec une fiche vide, pour être sûr qu'une valeur est quand même obtenue.
@ -665,3 +665,3 @@
warnings.warn('Deprecated access to formdef', DeprecationWarning)
return self._formdef
raise AttributeError('No such attribute %r' % attribute)
raise AttributeError(attribute)
En passant sur l'AttributeError je me rends compte que ça devrait juste lever l'attribut en paramètre, ça se trouve dans le code initialement concerné par le ticket et à un autre endroit (ici), je le modifie dans un petit commit supplémentaire.
@ -1907,0 +1907,4 @@
value = [CompatibilityNamesDict({'X': x})[f'X_{key}'] for x in self]
except KeyError:
raise AttributeError(str(key))
return value
Mise en place de la suggestion de Benjamin.
(prise en compte)