#29711: One can use as actions functions generated only by the first call to
another function
-------------------------------+--------------------------------------
Reporter: przemub | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.admin | Version: 2.1
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Carlton Gibson):
* status: new => closed
* resolution: => invalid
Comment:
The issue
[https://github.com/django/django/blob/7b7fb2eca51dacb5002a4e6b6e1417b36bd5dfd7/django/contrib/admin/options.py#L902-L906
occurs here in the `get_actions()` call]:
{{{
# Convert the actions into an OrderedDict keyed by name.
return OrderedDict(
(name, (func, name, desc))
for func, name, desc in actions
)
}}}
Here you've got two pairs of `(func, name, desc)` tuples keyed by the
`immediately` and `queue` names. Thus when they're passed to the
`OrderedDict` constructor, the keys conflict.
> And only functions generated by the first call to action() get added...
This doesn't seem right. We should expect the opposite:
> If a key occurs more than once, the last value for that key becomes the
corresponding value in the new dictionary.
> [https://docs.python.org/3.7/library/stdtypes.html#dict Python Docs]
The
[https://github.com/django/django/blob/7b7fb2eca51dacb5002a4e6b6e1417b36bd5dfd7/django/contrib/admin/options.py#L928
`name` comes from the `__name__` attribute of the action function].
You should be able to adjust this to ensure unique names.
Perhaps something like:
{{{
immediately.__name__ = 'immediately_{}'.format(fun.__name__)
}}}
... and so on.
--
Ticket URL: <https://code.djangoproject.com/ticket/29711#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.accee4f0a7728a4d24ff5e770b2a141d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.