%PDF- %PDF-
Direktori : /lib/python3/dist-packages/zope/interface/__pycache__/ |
Current File : //lib/python3/dist-packages/zope/interface/__pycache__/adapter.cpython-312.pyc |
� ��ez� � � � d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddlm Z ddl mZ dd l mZ d dgZ G d� d � Z e� Ze G d� d� � Ze G d� de� � Z G d� d� Z G d� dee� Z ee � G d� d e� � Z G d� dee� Z ee � G d� de� � Zd� Zd� Zd� Zd� Zy)zAdapter management � N)�implementer)� providedBy�� Interface)�ro)�IAdapterRegistry)�_normalize_name)�_use_c_impl�AdapterRegistry�VerifyingAdapterRegistryc �� � e Zd ZdZdZdZdd�Zd� Z ed� d� � Z d� Z eZe ZeZeZd � Zd � Zd� Zd� Zd � Zdd�Zedd�� Zd� Zd� Zdd�Zd� Zd� Zd� Zdd�Z d� Z!d� Z"y)�BaseAdapterRegistrya� A basic implementation of the data storage and algorithms required for a :class:`zope.interface.interfaces.IAdapterRegistry`. Subclasses can set the following attributes to control how the data is stored; in particular, these hooks can be helpful for ZODB persistence. They can be class attributes that are the named (or similar) type, or they can be methods that act as a constructor for an object that behaves like the types defined here; this object will not assume that they are type objects, but subclasses are free to do so: _sequenceType = list This is the type used for our two mutable top-level "byorder" sequences. Must support mutation operations like ``append()`` and ``del seq[index]``. These are usually small (< 10). Although at least one of them is accessed when performing lookups or queries on this object, the other is untouched. In many common scenarios, both are only required when mutating registrations and subscriptions (like what :meth:`zope.interface.interfaces.IComponents.registerUtility` does). This use pattern makes it an ideal candidate to be a :class:`~persistent.list.PersistentList`. _leafSequenceType = tuple This is the type used for the leaf sequences of subscribers. It could be set to a ``PersistentList`` to avoid many unnecessary data loads when subscribers aren't being used. Mutation operations are directed through :meth:`_addValueToLeaf` and :meth:`_removeValueFromLeaf`; if you use a mutable type, you'll need to override those. _mappingType = dict This is the mutable mapping type used for the keyed mappings. A :class:`~persistent.mapping.PersistentMapping` could be used to help reduce the number of data loads when the registry is large and parts of it are rarely used. Further reductions in data loads can come from using a :class:`~BTrees.OOBTree.OOBTree`, but care is required to be sure that all required/provided values are fully ordered (e.g., no required or provided values that are classes can be used). _providedType = dict This is the mutable mapping type used for the ``_provided`` mapping. This is separate from the generic mapping type because the values are always integers, so one might choose to use a more optimized data structure such as a :class:`~BTrees.OIBTree.OIBTree`. The same caveats regarding key types apply as for ``_mappingType``. It is possible to also set these on an instance, but because of the need to potentially also override :meth:`_addValueToLeaf` and :meth:`_removeValueFromLeaf`, this may be less useful in a persistent scenario; using a subclass is recommended. .. versionchanged:: 5.3.0 Add support for customizing the way internal data structures are created. .. versionchanged:: 5.3.0 Add methods :meth:`rebuild`, :meth:`allRegistrations` and :meth:`allSubscriptions`. ) �lookup�queryMultiAdapter�lookup1�queryAdapter�adapter_hook� lookupAll�names� subscriptions�subscribersr c � � | j � | _ | j � | _ | j � | _ | j � || _ y �N)� _sequenceType� _adapters�_subscribers� _providedType� _provided� _createLookup� __bases__��self�basess �8/usr/lib/python3/dist-packages/zope/interface/adapter.py�__init__zBaseAdapterRegistry.__init__� sP � � �+�+�-��� !�.�.�0��� �+�+�-��� ���� ��� c �x � || j d<