
    Of'                        d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
 dd	lmZ d
dgZ G d d          Z e            Ze
 G d d                      Ze
 G d de                      Z G d d          Z G d dee          Z ee           G d d
e                      Z G d dee          Z ee           G d de                      Zd Zd Zd Zd ZdS )zAdapter management
    N	Interface)implementer
providedBy)ro)_normalize_name)_use_c_impl)IAdapterRegistryAdapterRegistryVerifyingAdapterRegistryc                       e Zd ZdZdZdZddZd Z ed d           Z	d	 Z
eZeZeZeZd
 Zd Zd Zd Zd ZddZedd            Zd Zd ZddZd Zd Zd ZddZ d Z!d Z"dS )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                     |                                  | _        |                                  | _        |                                 | _        |                                  || _        d S N)_sequenceType	_adapters_subscribers_providedType	_provided_createLookup	__bases__selfbasess     H/var/www/html/env/lib/python3.11/site-packages/zope/interface/adapter.py__init__zBaseAdapterRegistry.__init__   sc     ++-- !..00 ++--  	     c                 v    || j         d<   t          j        |           | _        |                     |            dS )z
        If subclasses need to track when ``__bases__`` changes, they
        can override this method.

        Subclasses must still call this method.
        r"   N)__dict__r   changedr#   s     r&   	_setBaseszBaseAdapterRegistry._setBases   s7     &+k"%++Tr(   c                     | j         d         S )Nr"   )r*   r$   s    r&   <lambda>zBaseAdapterRegistry.<lambda>   s    dmK&@ r(   c                 ,    |                      |          S r   )r,   r#   s     r&   r/   zBaseAdapterRegistry.<lambda>   s    T^^E-B-B r(   c                     |                      |           | _        | j        D ]}t          | j        |          | j        |<    d S r   )LookupClass	_v_lookup
_delegatedgetattrr*   )r$   names     r&   r!   z!BaseAdapterRegistry._createLookup   sQ    ))$//O 	@ 	@D")$.$"?"?DM$	@ 	@r(   c                     ||fS ||fz   S )a)  
        Add the value *new_item* to the *existing_leaf_sequence*, which may
        be ``None``.

        Subclasses that redefine `_leafSequenceType` should override this
        method.

        :param existing_leaf_sequence:
            If *existing_leaf_sequence* is not *None*, it will be an instance
            of `_leafSequenceType`. (Unless the object has been unpickled from
            an old pickle and the class definition has changed, in which case
            it may be an instance of a previous definition, commonly a
            `tuple`.)

        :return:
           This method returns the new value to be stored. It may mutate the
           sequence in place if it was not ``None`` and the type is mutable,
           but it must also return it.

        .. versionadded:: 5.3.0
        r   )r$   existing_leaf_sequencenew_items      r&   _addValueToLeafz#BaseAdapterRegistry._addValueToLeaf   s    , ");%33r(   c                 :    t          fd|D                       S )aa  
        Remove the item *to_remove* from the (non-``None``, non-empty)
        *existing_leaf_sequence* and return the mutated sequence.

        If there is more than one item that is equal to *to_remove*
        they must all be removed.

        Subclasses that redefine `_leafSequenceType` should override
        this method. Note that they can call this method to help
        in their implementation; this implementation will always
        return a new tuple constructed by iterating across
        the *existing_leaf_sequence* and omitting items equal to *to_remove*.

        :param existing_leaf_sequence:
           As for `_addValueToLeaf`, probably an instance of
           `_leafSequenceType` but possibly an older type; never `None`.
        :return:
           A version of *existing_leaf_sequence* with all items equal to
           *to_remove* removed. Must not return `None`. However,
           returning an empty
           object, even of another type such as the empty tuple, ``()`` is
           explicitly allowed; such an object will never be stored.

        .. versionadded:: 5.3.0
        c                      g | ]
}|k    |S r   r   ).0v	to_removes     r&   
<listcomp>z<BaseAdapterRegistry._removeValueFromLeaf.<locals>.<listcomp>  s    JJJA1	>>a>>>r(   )tuple)r$   r8   r?   s     `r&   _removeValueFromLeafz(BaseAdapterRegistry._removeValueFromLeaf   s)    4 JJJJ!7JJJKKKr(   c                 Z    | xj         dz  c_         | j                            |           d S N   )_generationr3   r+   r$   originally_changeds     r&   r+   zBaseAdapterRegistry.changed
  s3    A122222r(   c                    t          |t                    st          d          ||                     ||||           d S t	          d |D                       }t          |          }t          |          }| j        }t          |          |k    r:|                    | 	                                           t          |          |k    :||         }||fz   }|D ]4}	|
                    |	          }
|
| 	                                }
|
||	<   |
}5|
                    |          |u rd S |||<   | j        
                    |d          dz   }|| j        |<   |dk    r| j                            |           |                     |            d S )Nname is not a stringc                 ,    g | ]}t          |          S r   _convert_None_to_Interfacer=   rs     r&   r@   z0BaseAdapterRegistry.register.<locals>.<listcomp>  !    JJJA4Q77JJJr(   r   rE   )
isinstancestr
ValueError
unregisterrA   r	   lenr   append_mappingTypegetr    r3   add_extendorr+   )r$   requiredprovidedr6   valueorderbyorder
componentskeykdns               r&   registerzBaseAdapterRegistry.register  s   $$$ 	53444=OOHhe<<<FJJJJJKKt$$H.'lle##NN4,,../// 'lle##U^
($ 	 	Aq!!Ay%%'' !
1JJ>>$5((F 
4Nx++a/#$x 66N''111Tr(   c                    t          d |D                       }t          |          }t          |          |k    rd S ||         }||fz   }|D ]}|                    |          }	|	 d S |	}|                    |          S )Nc                 ,    g | ]}t          |          S r   rL   rN   s     r&   r@   z2BaseAdapterRegistry._find_leaf.<locals>.<listcomp>7  rP   r(   )rA   rU   rX   )
r$   r^   rZ   r[   r6   r]   r_   r`   ra   rb   s
             r&   
_find_leafzBaseAdapterRegistry._find_leaf1  s     JJJJJKKHw<<5  4U^
($ 	 	Aq!!AyttJJ~~d###r(    c                 V    |                      | j        ||t          |                    S r   )rg   r   r	   )r$   rZ   r[   r6   s       r&   
registeredzBaseAdapterRegistry.registeredG  s.    ND!!	
 
 	
r(   c              #      K   |dk    r&|                                 D ]\  }}||fz   |fV  d S |                                 D ]+\  }}||fz   }|                     ||dz
  |          E d {V  ,d S )Nr   rE   )items_allKeys)clsr_   iparent_kra   r>   new_parent_ks          r&   rm   zBaseAdapterRegistry._allKeysO  s      66"((** ) )1!oq((((() ) #((** @ @1'1$<<1q5,??????????@ @r(   c              #      K   t          |          D ]^\  }}|                     ||dz             D ]?\  }}t          |          |dz   k    sJ |d |         }|d         }|d         }||||fV  @_d S )NrE      )	enumeraterm   rU   )	r$   r^   ro   r_   r`   r\   rZ   r[   r6   s	            r&   _all_entriesz BaseAdapterRegistry._all_entriesY  s       'w// 	8 	8MAz #mmJA>> 8 8
U3xx1q5((((rr7r72w4777778	8 	8r(   c              #   J   K   |                      | j                  E d{V  dS )aT  
        Yields tuples ``(required, provided, name, value)`` for all
        the registrations that this object holds.

        These tuples could be passed as the arguments to the
        :meth:`register` method on another adapter registry to
        duplicate the registrations this object holds.

        .. versionadded:: 5.3.0
        N)rw   r   r.   s    r&   allRegistrationsz$BaseAdapterRegistry.allRegistrationsk  s6       $$T^44444444444r(   Nc                    t          d |D                       }t          |          }| j        }|t          |          k    rdS ||         }||fz   }g }	|D ]5}
|                    |
          }| d S |	                    ||
f           |}6|                    |          }|d S |||urd S ||= |s;t          |	          D ]\  }}
||
         }|r n||
= |r|d         s|d= |r|d         | j        |         dz
  }|dk    r#| j        |= | j                            |           n
|| j        |<   | 	                    |            d S )Nc                 ,    g | ]}t          |          S r   rL   rN   s     r&   r@   z2BaseAdapterRegistry.unregister.<locals>.<listcomp>y  rP   r(   Fru   rE   r   )
rA   rU   r   rX   rV   reversedr    r3   remove_extendorr+   )r$   rZ   r[   r6   r\   r]   r^   r_   r`   lookupsra   rb   oldcomprc   s                  r&   rT   zBaseAdapterRegistry.unregisterx  s   JJJJJKKH.CLL  5U^
($  	 	Aq!!AyNNJ?+++JJnnT"";FCu$4$4Ft 	  $G,,    aG  EQ  '"+  BK   '"+  N8$q(66x(N**84444'(DN8$Tr(   c                    t          d |D                       }d}t          |          }| j        }t          |          |k    r:|                    |                                            t          |          |k    :||         }||fz   }|D ]4}	|                    |	          }
|
|                                 }
|
||	<   |
}5|                     |                    |          |          ||<   |H| j                            |d          dz   }|| j        |<   |dk    r| j        	                    |           | 
                    |            d S )Nc                 ,    g | ]}t          |          S r   rL   rN   s     r&   r@   z1BaseAdapterRegistry.subscribe.<locals>.<listcomp>  rP   r(   rh   r   rE   )rA   rU   r   rV   rW   rX   r:   r    r3   rY   r+   )r$   rZ   r[   r\   r6   r]   r^   r_   r`   ra   rb   rc   s               r&   	subscribezBaseAdapterRegistry.subscribe  s^   JJJJJKKH#'lle##NN4,,../// 'lle##U^
($ 	 	Aq!!Ay%%'' !
1JJ//
t0D0DeLL
4""8Q//!3A'(DN8$Avv++H555Tr(   c                 P    |                      | j        ||d          pd}||v r|nd S )Nrh   r   )rg   r   )r$   rZ   r[   
subscriberr   s        r&   
subscribedzBaseAdapterRegistry.subscribed  sG    oo	
 
 
  	 (;66zzD@r(   c              #   f   K   |                      | j                  D ]\  }}}}|D ]	}|||fV  
dS )aM  
        Yields tuples ``(required, provided, value)`` for all the
        subscribers that this object holds.

        These tuples could be passed as the arguments to the
        :meth:`subscribe` method on another adapter registry to
        duplicate the registrations this object holds.

        .. versionadded:: 5.3.0
        N)rw   r   )r$   rZ   r[   _namer\   r>   s         r&   allSubscriptionsz$BaseAdapterRegistry.allSubscriptions  sl       150A0A1
 1
 	. 	.,Hhu  . .1-----.	. 	.r(   c                 0   t          d |D                       }t          |          }| j        }|t          |          k    rd S ||         }||fz   }g }|D ]5}	|                    |	          }
|
 d S |                    ||	f           |
}6|                    d          }|sd S t          |          }|d}n|                     ||          }~t          |          |k    rd S |r||d<   n>|d= t          |          D ]\  }}	||	         }
|
r n||	= |r|d         s|d= |r|d         |S| j        |         t          |          z   |z
  }|dk    r#| j        |= | j        	                    |           n
|| j        |<   | 
                    |            d S )Nc                 ,    g | ]}t          |          S r   rL   rN   s     r&   r@   z3BaseAdapterRegistry.unsubscribe.<locals>.<listcomp>  rP   r(   rh   r   ru   r   )rA   rU   r   rX   rV   rB   r|   r    r3   r}   r+   )r$   rZ   r[   r\   r]   r^   r_   r`   r~   ra   rb   r   len_oldnewr   rc   s                   r&   unsubscribezBaseAdapterRegistry.unsubscribe  s   JJJJJKKH#CLL  FU^
($  	 	Aq!!AyNNJ?+++JJnnR   	Fc((=
 CC++C77C s88wF 	  JrNN 2#G,,    aG  EQ  '"+  BK   '"+   x(3s883g=AAvvN8,..x8888+,x(Tr(   c                     |                                  }|                                 }d } ||          } ||          }|                     | j                   |D ]} | j        |  |D ]} | j        |  dS )aE  
        Rebuild (and replace) all the internal data structures of this
        object.

        This is useful, especially for persistent implementations, if
        you suspect an issue with reference counts keeping interfaces
        alive even though they are no longer used.

        It is also useful if you or a subclass change the data types
        (``_mappingType`` and friends) that are to be used.

        This method replaces all internal data structures with new objects;
        it specifically does not re-use any storage.

        .. versionadded:: 5.3.0
        c                     	 t          |           }n# t          $ r t          d          cY S w xY wt          j        |f|           S )Nr   )nextStopIterationiter	itertoolschain)itfirsts     r&   bufferz+BaseAdapterRegistry.rebuild.<locals>.buffer8  sT     R       Bxx  ?E8R000s    ..N)ry   r   r'   r"   rd   r   )r$   registrationsr   r   argss        r&   rebuildzBaseAdapterRegistry.rebuild"  s    & --//--//		1 		1 		1 }--}-- 	dn%%% " 	! 	!DDM4   ! 	" 	"DDND!!!	" 	"r(   c                       G d d          }|S )Nc                       e Zd Zi ZdS )2BaseAdapterRegistry.get.<locals>.XXXTwistedFakeOutN)__name__
__module____qualname__selfImpliedr   r(   r&   XXXTwistedFakeOutr   Z  s        KKKr(   r   r   )r$   _r   s      r&   rX   zBaseAdapterRegistry.getY  s0    	 	 	 	 	 	 	 	  r(   r   rh   r   )#r   r   r   __doc__r4   rF   r'   r,   propertyr"   r!   listr   rA   _leafSequenceTypedictrW   r   r:   rB   r+   rd   rg   rj   classmethodrm   rw   ry   rT   r   r   r   r   r   rX   r   r(   r&   r   r   @   s       ; ;|2J K- - - -^	 	 	 @@BB I@ @ @ MLM4 4 44L L L83 3 3! ! !F$ $ $,
 
 
 
 @ @ @ [@8 8 8$5 5 5. . . .`  6A A A. . ."C C C CJ3" 3" 3"n! ! ! ! !r(   r   c                   X     e Zd Zd ZddZd ZddZddZddZd fd		Z	d
 Z
d Z xZS )
LookupBasec                 0    i | _         i | _        i | _        d S r   )_cache_mcache_scacher.   s    r&   r'   zLookupBase.__init__e  s    r(   Nc                     | j                                          | j                                         | j                                         d S r   )r   clearr   r   )r$   ignoreds     r&   r+   zLookupBase.changedj  sD    r(   c                     | j                             |          }|i }|| j         |<   |r |                    |          }|i }|||<   |}|S r   )r   rX   )r$   r[   r6   cachecs        r&   	_getcachezLookupBase._getcacheo  s_    ))=E$)DK! 			$AydEr(   rh   c                    t          |t                    st          d          |                     ||          }t	          |          }t          |          dk    r"|                    |d         t                    }n(|                    t	          |          t                    }|t          u rH|                     |||          }t          |          dk    r|||d         <   n||t	          |          <   ||S |S )NrJ   rE   r   )	rQ   rR   rS   r   rA   rU   rX   _not_in_mapping_uncached_lookupr$   rZ   r[   r6   defaultr   results          r&   r   zLookupBase.lookup|  s    $$$ 	53444x..??x==AYYx{O<<FFYYuX@@F_$$**8XtDDF8}}!!%+hqk"")/eHoo&>Nr(   c                     t          |t                    st          d          |                     ||          }|                    |t
                    }|t
          u r|                     |f|||          S ||S |S NrJ   )rQ   rR   rS   r   rX   r   r   r   s          r&   r   zLookupBase.lookup1  s}    $$$ 	53444x..8_55_$$;;|XtWEEE>Nr(   c                 2    |                      ||||          S r   )r   )r$   objectr[   r6   r   s        r&   r   zLookupBase.queryAdapter  s      64AAAr(   c                 l   t          |t                    st          d          t          |          }|                     ||          }|                    |t                    }|t          u r|                     |f||          }|+t          |t                    r|j	        } ||          }||S |S r   )
rQ   rR   rS   r   r   rX   r   r   super__self__)
r$   r[   r   r6   r   rZ   r   factoryr   	__class__s
            r&   r   zLookupBase.adapter_hook  s    $$$ 	53444f%%x..))Ho66o%%kk8,$??G&%(( )WV__F!r(   c                     | j                             |          }|i }|| j         |<   t          |          }|                    |t                    }|t          u r|                     ||          }|||<   |S r   )r   rX   rA   r   _uncached_lookupAllr$   rZ   r[   r   r   s        r&   r   zLookupBase.lookupAll  sy      **=E%*DL"??8_55_$$--hAAF$E(Or(   c                     | j                             |          }|i }|| j         |<   t          |          }|                    |t                    }|t          u r|                     ||          }|||<   |S r   )r   rX   rA   r   _uncached_subscriptionsr   s        r&   r   zLookupBase.subscriptions  sy      **=E%*DL"??8_55_$$11(HEEF$E(Or(   r   rh   N)r   r   r   r'   r+   r   r   r   r   r   r   r   __classcell__r   s   @r&   r   r   b  s          
   
     ,   B B B B     $        r(   r   c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )VerifyingBasec                     t                               | |           | j        j        dd          | _        d | j        D             | _        d S )NrE   c                     g | ]	}|j         
S r   rF   rN   s     r&   r@   z)VerifyingBase.changed.<locals>.<listcomp>  s    #K#K#KaAM#K#K#Kr(   )LookupBaseFallbackr+   	_registryr   
_verify_ro_verify_generationsrG   s     r&   r+   zVerifyingBase.changed  sL    ""4);<<<.+ABB/#K#K4?#K#K#K   r(   c                 h    d | j         D             | j        k    r|                     d            d S d S )Nc                     g | ]	}|j         
S r   r   rN   s     r&   r@   z)VerifyingBase._verify.<locals>.<listcomp>  s'       "#  r(   )r   r   r+   r.   s    r&   _verifyzVerifyingBase._verify  sT     '+  )* * LL	* *r(   c                 b    |                                   t                              | ||          S r   )r   r   r   )r$   r[   r6   s      r&   r   zVerifyingBase._getcache  s.    !++(D
 
 	
r(   c                 b    |                                   t                              | ||          S r   )r   r   r   r$   rZ   r[   s      r&   r   zVerifyingBase.lookupAll  s.    !++(H
 
 	
r(   c                 b    |                                   t                              | ||          S r   )r   r   r   r   s      r&   r   zVerifyingBase.subscriptions  s.    !//(H
 
 	
r(   N)r   r   r   r+   r   r   r   r   r   r(   r&   r   r     sb        L L L
  
 
 

 
 

 
 
 
 
r(   r   c                   n     e Zd Z fdZd fd	Zd Zd Zd Zd Zdd	Z	d fd
	Z
d Zd Zd Zd Z xZS )AdapterLookupBasec                     || _         i | _        |                                  t                                                       d S r   )r   	_requiredinit_extendorsr   r'   )r$   registryr   s     r&   r'   zAdapterLookupBase.__init__  s?    !r(   Nc                     t                                          d            | j                                        D ]#} |            }||                    |            $| j                                         d S r   )r   r+   r   keysr   r   )r$   r   rO   r   s      r&   r+   zAdapterLookupBase.changed   ss    $$&& 	$ 	$AA}d###r(   c                 \    i | _         | j        j        D ]}|                     |           d S r   )
_extendorsr   r    rY   )r$   ps     r&   r   z AdapterLookupBase.init_extendors  s>    ) 	! 	!Aa    	! 	!r(   c                     | j         }j        D ]<}|                    |d          }fd|D             gz   fd|D             z   ||<   =d S )Nr   c                 >    g | ]}                     |          |S r   isOrExtendsr=   er[   s     r&   r@   z2AdapterLookupBase.add_extendor.<locals>.<listcomp>(  s<       H,@,@,C,C  r(   c                 >    g | ]}                     |          |S r   r   r   s     r&   r@   z2AdapterLookupBase.add_extendor.<locals>.<listcomp>,  s<       0D0DQ0G0G  r(   r   __iro__rX   )r$   r[   r   ro   	extendorss    `   r&   rY   zAdapterLookupBase.add_extendor#  s    _
! 
	 
	A"q"--I   (      (  	 qMM
	 
	r(   c                 t    | j         }j        D ]'}fd|                    |d          D             ||<   (d S )Nc                      g | ]
}|k    |S r   r   r   s     r&   r@   z5AdapterLookupBase.remove_extendor.<locals>.<listcomp>4  s)     / / /1 !X  -r(   r   r   )r$   r[   r   ro   s    `  r&   r}   z!AdapterLookupBase.remove_extendor1  sa    _
! 	/ 	/A/ / / /
q"(=(= / / /JqMM	/ 	/r(   c                     | j         }|D ]4}|                                }||vr|                    |            d||<   5d S rD   )r   weakrefr   )r$   rZ   _refsrO   refs        r&   
_subscribezAdapterLookupBase._subscribe7  sV     	 	A))++C%D!!!c
		 	r(   rh   c           	      2   t          |          }d }t          |          }| j        j        D ]_}|j        }|t          |          k    r|j        j                            |          }|s?||         }	t          |	|||d|          }| n` | j	        |  |S Nr   )
rA   rU   r   r   r   r3   r   rX   _lookupr   )
r$   rZ   r[   r6   r   r]   r   r^   r   r_   s
             r&   r   z"AdapterLookupBase._uncached_lookup?  s    ??H) 	 	H(GG$$ *599(CCI  JZ9dA"$ $F! " 	""r(   c                 |    |                      d |D             ||          }||S  |fd|D              }||S |S )Nc                 ,    g | ]}t          |          S r   r   r=   os     r&   r@   z7AdapterLookupBase.queryMultiAdapter.<locals>.<listcomp>W  s    >>>z!}}>>>r(   c                 L    g | ] }t          |t                    r|j        n|!S r   )rQ   r   r   )r=   r  r   s     r&   r@   z7AdapterLookupBase.queryMultiAdapter.<locals>.<listcomp>[  s;     
 
 
:;*Q..5AJJA
 
 
r(   )r   )r$   objectsr[   r6   r   r   r   r   s          r&   r   z#AdapterLookupBase.queryMultiAdapterV  st    ++>>g>>>$OO?N 
 
 
 
?F
 
 
  >Nr(   c           	         t          |          }t          |          }i }t          | j        j                  D ][}|j        }|t          |          k    r|j        j                            |          }|s?||         }t          ||||d|           \ | j
        |  t          |                                          S r   )rA   rU   r|   r   r   r   r3   r   rX   
_lookupAllr   rl   )	r$   rZ   r[   r]   r   r   r^   r   r_   s	            r&   r   z%AdapterLookupBase._uncached_lookupAllc  s    ??H !233 	J 	JH(GG$$ *599(CCI  Jz8Y5IIII""V\\^^$$$r(   c                 B    d |                      ||          D             S )Nc                     g | ]
}|d          S )r   r   )r=   r   s     r&   r@   z+AdapterLookupBase.names.<locals>.<listcomp>v  s    AAA!AAAr(   )r   r   s      r&   r   zAdapterLookupBase.namesu  s$    AAdnnXx@@AAAAr(   c           
      N   t          |          }t          |          }g }t          | j        j                  D ]`}|j        }|t          |          k    r||f}n"|j        j                            |          }|Et          ||         ||d|d|           a | j
        |  |S )Nrh   r   )rA   rU   r|   r   r   r   r3   r   rX   _subscriptionsr   )r$   rZ   r[   r]   r   r   r^   r   s           r&   r   z)AdapterLookupBase._uncached_subscriptionsx  s    ??H !233 	- 	-H+GG$$%L		$.9==hGG	$75>8Y!1e- - - - 	""r(   c                     |                      d |D             |          }|d}|D ]} ||  n#g }|D ]} || }||                    |           |S )Nc                 ,    g | ]}t          |          S r   r   r  s     r&   r@   z1AdapterLookupBase.subscribers.<locals>.<listcomp>  s    ,,,qZ]],,,r(   r   )r   rV   )r$   r  r[   r   r   subscriptionr   s          r&   r   zAdapterLookupBase.subscribers  s    **,,G,,,h
 
 F - ' 'g&&&' F - . .)\73
)MM*---r(   r   r   r   )r   r   r   r'   r+   r   rY   r}   r   r   r   r   r   r   r   r   r   s   @r&   r   r     s                <! ! !
  / / /     .     % % %$B B B  .      r(   r   c                       e Zd ZdS )AdapterLookupNr   r   r   r   r(   r&   r  r            Dr(   r  c                   H     e Zd ZdZeZd fd	Zd Zd Z fdZ	 fdZ
 xZS )	r   za
    A full implementation of ``IAdapterRegistry`` that adds support for
    sub-registries.
    r   c                 z    t          j                    | _        t                                          |           d S r   )r   WeakKeyDictionary_v_subregistriesr   r'   )r$   r%   r   s     r&   r'   zAdapterRegistry.__init__  s4     !( 9 ; ;r(   c                     d| j         |<   d S rD   r  r$   rO   s     r&   _addSubregistryzAdapterRegistry._addSubregistry  s    #$a   r(   c                 ,    || j         v r
| j         |= d S d S r   r  r  s     r&   _removeSubregistryz"AdapterRegistry._removeSubregistry  s)    %%%%a((( &%r(   c                     | j                             dd          }|D ]}||vr|                    |            |D ]}||vr|                    |            t	                                          |           d S )Nr"   r   )r*   rX   r  r  r   r,   )r$   r%   r   rO   r   s       r&   r,   zAdapterRegistry._setBases  s    mR00 	+ 	+A~~$$T*** 	( 	(A||!!$'''%     r(   c                     t                                          |           | j                                        D ]}|                    |           d S r   )r   r+   r  r   )r$   rH   subr   s      r&   r+   zAdapterRegistry.changed  sX    *+++(--// 	, 	,CKK*++++	, 	,r(   r   )r   r   r   r   r  r2   r'   r  r  r,   r+   r   r   s   @r&   r   r     s         
  K           % % %) ) )	! 	! 	! 	! 	!, , , , , , , , ,r(   c                       e Zd ZdS )VerifyingAdapterLookupNr  r   r(   r&   r!  r!    r  r(   r!  c                       e Zd ZdZeZdS )r   z2
    The most commonly-used adapter registry.
    N)r   r   r   r   r!  r2   r   r(   r&   r   r     s          )KKKr(   c                     | t           S | S r   r   )xs    r&   rM   rM     s    yr(   c           	          | j         }||k     r;||         j        D ],} ||          }|rt          |||||dz   |          }	|	|	c S -n-|D ]*}
 ||
          }|r|                     |          }	|	|	c S +d S rD   )rX   __sro__r   )r_   specsr[   r6   ro   lcomponents_getspeccompsrO   ifaces              r&   r   r     s    
  ^N1uu!H$ 	 	D"N4((E E5(D!a%CC=HHH	  	 	E"N5))E IIdOO=HHH4r(   c           	         | j         }||k     rCt          ||         j                  D ]&} ||          }|rt          |||||dz   |           'd S t          |          D ]$}	 ||	          }|r|                    |           %d S rD   )rX   r|   r&  r  update)
r_   r'  r[   r   ro   r(  r)  r*  r+  r,  s
             r&   r  r    s    ^N1uuU1X-.. 	E 	ED"N4((E E5%61q5!DDD	E 	E
 h'' 	% 	%E"N5))E %e$$$	% 	%r(   c           
      >   | j         }||k     rDt          ||         j                  D ]'} ||          }	|	rt          |	|||||dz   |           (d S t          |          D ];}
 ||
          }	|	r,|	                     |          }	|	r|                    |	           <d S rD   )rX   r|   r&  r  extend)r_   r'  r[   r6   r   ro   r(  r)  r*  r+  r,  s              r&   r  r    s      ^N1uuU1X-.. 	 	D"N4((E 5(D&!a%  	 	 h'' 	) 	)E"N5))E )		$ )MM%(((	) 	)r(   )r   r   r   zope.interfacer   r   r   r   zope.interface._compatr	   r
   zope.interface.interfacesr   __all__r   r   r   r   r   r   r   r  r   r!  r   rM   r   r  r  r   r(   r&   <module>r5     s         $ $ $ $ $ $ & & & & & & % % % % % %       2 2 2 2 2 2 . . . . . . 6 6 6 6 6 6 H\! \! \! \! \! \! \! \!~ &(( k k k k k k k k\ #
 #
 #
 #
 #
& #
 #
 #
Le e e e e e e eP	 	 	 	 	%z 	 	 	 %, %, %, %, %,) %, %, %,P	 	 	 	 	. 	 	 	 ) ) ) ) )2 ) ) )    0% % %) ) ) ) )r(   