Set the *cls* component in the *name* :ref:`component priority dictionary <component-priority-dictionaries>` setting with *priority*. If *cls* already exists, its value is updated. If *cls* was present as an import string, even more than once, those keys are dropped
(
self, name: _SettingsKey, cls: type, priority: int | None
)
| 487 | self.attributes[name].set(value, priority) |
| 488 | |
| 489 | def set_in_component_priority_dict( |
| 490 | self, name: _SettingsKey, cls: type, priority: int | None |
| 491 | ) -> None: |
| 492 | """Set the *cls* component in the *name* :ref:`component priority |
| 493 | dictionary <component-priority-dictionaries>` setting with *priority*. |
| 494 | |
| 495 | If *cls* already exists, its value is updated. |
| 496 | |
| 497 | If *cls* was present as an import string, even more than once, those |
| 498 | keys are dropped and replaced by *cls*. |
| 499 | |
| 500 | This change is applied regardless of the priority of the *name* |
| 501 | setting. The setting priority is not affected by this change either. |
| 502 | """ |
| 503 | component_priority_dict = self.getdict(name) |
| 504 | for cls_or_path in tuple(component_priority_dict): |
| 505 | if not isinstance(cls_or_path, str): |
| 506 | continue |
| 507 | _cls = load_object(cls_or_path) |
| 508 | if _cls == cls: |
| 509 | del component_priority_dict[cls_or_path] |
| 510 | component_priority_dict[cls] = priority |
| 511 | self.set(name, component_priority_dict, self.getpriority(name) or 0) |
| 512 | |
| 513 | def setdefault( # pylint: disable=arguments-renamed |
| 514 | self, |