A collection-holding attribute that instruments changes in membership. Only handles collections of instrumented objects. InstrumentedCollectionAttribute holds an arbitrary, user-specified container object (defaulting to a list) and brokers access to the CollectionAdapter, a "view"
| 1630 | |
| 1631 | |
| 1632 | class _CollectionAttributeImpl(_HasCollectionAdapter, _AttributeImpl): |
| 1633 | """A collection-holding attribute that instruments changes in membership. |
| 1634 | |
| 1635 | Only handles collections of instrumented objects. |
| 1636 | |
| 1637 | InstrumentedCollectionAttribute holds an arbitrary, user-specified |
| 1638 | container object (defaulting to a list) and brokers access to the |
| 1639 | CollectionAdapter, a "view" onto that object that presents consistent bag |
| 1640 | semantics to the orm layer independent of the user data implementation. |
| 1641 | |
| 1642 | """ |
| 1643 | |
| 1644 | uses_objects = True |
| 1645 | collection = True |
| 1646 | default_accepts_scalar_loader = False |
| 1647 | supports_population = True |
| 1648 | dynamic = False |
| 1649 | |
| 1650 | _bulk_replace_token: AttributeEventToken |
| 1651 | |
| 1652 | __slots__ = ( |
| 1653 | "copy", |
| 1654 | "collection_factory", |
| 1655 | "_append_token", |
| 1656 | "_remove_token", |
| 1657 | "_bulk_replace_token", |
| 1658 | "_duck_typed_as", |
| 1659 | ) |
| 1660 | |
| 1661 | def __init__( |
| 1662 | self, |
| 1663 | class_, |
| 1664 | key, |
| 1665 | callable_, |
| 1666 | dispatch, |
| 1667 | typecallable=None, |
| 1668 | trackparent=False, |
| 1669 | copy_function=None, |
| 1670 | compare_function=None, |
| 1671 | **kwargs, |
| 1672 | ): |
| 1673 | super().__init__( |
| 1674 | class_, |
| 1675 | key, |
| 1676 | callable_, |
| 1677 | dispatch, |
| 1678 | trackparent=trackparent, |
| 1679 | compare_function=compare_function, |
| 1680 | **kwargs, |
| 1681 | ) |
| 1682 | |
| 1683 | if copy_function is None: |
| 1684 | copy_function = self.__copy |
| 1685 | self.copy = copy_function |
| 1686 | self.collection_factory = typecallable |
| 1687 | self._append_token = AttributeEventToken(self, OP_APPEND) |
| 1688 | self._remove_token = AttributeEventToken(self, OP_REMOVE) |
| 1689 | self._bulk_replace_token = AttributeEventToken(self, OP_BULK_REPLACE) |
no outgoing calls
no test coverage detected