
    (ph'                        S r SSKrSSKrSSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSKJ
r
  SS	KJr  S
S/r " S S5      r\" 5       r\
 " S S5      5       r\
 " S S\5      5       r " S S5      r " S S\\5      r\" \5       " S S
\5      5       r " S S\\5      r\" \5       " S S\5      5       rS rS rS rS rg)zAdapter management
    N	Interface)implementer)
providedBy)ro)_normalize_name)_use_c_impl)IAdapterRegistryAdapterRegistryVerifyingAdapterRegistryc                       \ rS rSrSrSrSrSS jrS r\	" S S 5      r
S	 r\r\r\r\rS
 rS rS rS rS rSS jr\SS j5       rS rS rSS jrS rS rS r SS jr!S r"S r#Sr$g)BaseAdapterRegistry@   a  
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                     U R                  5       U l        U R                  5       U l        U R                  5       U l        U R                  5         Xl        g N)_sequenceType	_adapters_subscribers_providedType	_provided_createLookup	__bases__selfbasess     I/var/www/html/venv/lib/python3.13/site-packages/zope/interface/adapter.py__init__BaseAdapterRegistry.__init__   sN     ++- !..0 ++-  	     c                 x    XR                   S'   [        R                  " U 5      U l        U R                  U 5        g)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%   	_setBasesBaseAdapterRegistry._setBases   s+     &+k"%%+Tr(   c                      U R                   S   $ )Nr!   )r*   r#   s    r%   <lambda>BaseAdapterRegistry.<lambda>   s    dmmK&@r(   c                 $    U R                  U5      $ r   )r,   r"   s     r%   r0   r1      s    T^^E-Br(   c                     U R                  U 5      U l        U R                   H&  n[        U R                  U5      U R                  U'   M(     g r   )LookupClass	_v_lookup
_delegatedgetattrr*   )r#   names     r%   r    !BaseAdapterRegistry._createLookup   s;    ))$/OOD")$..$"?DMM$ $r(   c                     Uc  U4$ X4-   $ )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#   existing_leaf_sequencenew_items      r%   _addValueToLeaf#BaseAdapterRegistry._addValueToLeaf   s    , ");%33r(   c                 R    [        U Vs/ s H  o3U:w  d  M
  UPM     sn5      $ s  snf )a  
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
)tuple)r#   r<   	to_removevs       r%   _removeValueFromLeaf(BaseAdapterRegistry._removeValueFromLeaf   s(    4 !7J!7A	>a!7JKKJs   	$$c                 d    U =R                   S-  sl         U R                  R                  U5        g N   )_generationr5   r+   )r#   originally_changeds     r%   r+   BaseAdapterRegistry.changed
  s&    A12r(   c                    [        U[        5      (       d  [        S5      eUc  U R                  XX45        g [	        U Vs/ s H  n[        U5      PM     sn5      n[        U5      n[        U5      nU R                  n[        U5      U::  a0  UR                  U R                  5       5        [        U5      U::  a  M0  Xv   nX4-   n	U	 H-  n
UR                  U
5      nUc  U R                  5       nXU
'   UnM/     UR                  U5      UL a  g XHU'   U R                  R                  US5      S-   nXR                  U'   US:X  a  U R                  R                  U5        U R                  U 5        g s  snf )Nname is not a stringr   rH   )
isinstancestr
ValueError
unregisterrA   _convert_None_to_Interfacer   lenr   append_mappingTypegetr   r5   add_extendorr+   )r#   requiredprovidedr8   valuerorderbyorder
componentskeykdns                r%   registerBaseAdapterRegistry.register  sS   $$$344=OOH<JA4Q7JKt$H..'le#NN4,,./ 'le#^
$Aq!Ay%%' !1J  >>$5( 4NNx+a/#$x 6NN''1T5 Ks    E2c                    [        U Vs/ s H  n[        U5      PM     sn5      n[        U5      n[        U5      U::  a  g X   nX#4-   nU H  n	UR                  U	5      n
U
c    g U
nM     UR                  U5      $ s  snf r   )rA   rR   rS   rV   )r#   r]   rX   rY   r8   r[   r\   r^   r_   r`   ra   s              r%   
_find_leafBaseAdapterRegistry._find_leaf1  s     JA4Q7JKHw<5 ^
$Aq!AyJ	  ~~d## Ks   A<c                 P    U R                  U R                  UU[        U5      5      $ r   )rf   r   r   )r#   rX   rY   r8   s       r%   
registeredBaseAdapterRegistry.registeredG  s(    NND!	
 	
r(   c              #      #    US:X  a#  UR                  5        H  u  pEX44-   U4v   M     g UR                  5        H'  u  pEX44-   nU R                  XRS-
  U5       S h  vN   M)     g  N	7f)Nr   rH   )items_allKeys)clsr^   iparent_kr`   rC   new_parent_ks          r%   rm   BaseAdapterRegistry._allKeysO  sk     6"((*oq(( + #((*'$<<q5,??? +?s   AA*A(
A*c              #      #    [        U5       HK  u  p#U R                  X2S-   5       H.  u  pE[        U5      US-   :X  d   eUS U nUS   nUS   nXgX4v   M0     MM     g 7f)NrH      )	enumeraterm   rS   )	r#   r]   ro   r^   r_   rZ   rX   rY   r8   s	            r%   _all_entries BaseAdapterRegistry._all_entriesY  sq      'w/MA #mmJA>
3x1q5(((r7r72w477 ? 0s   AAc              #   V   #    U R                  U R                  5       Sh  vN   g N7f)a  
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)rx   r   r/   s    r%   allRegistrations$BaseAdapterRegistry.allRegistrationsk  s      $$T^^444s   )')Nc                    [        U Vs/ s H  n[        U5      PM     sn5      n[        U5      nU R                  nU[        U5      :  a  gXv   nX4-   n	/ n
U	 H-  nUR	                  U5      nUc    g U
R                  X45        UnM/     UR	                  U5      nUc  g Ub  XLa  g X	 U(       dJ  [        U
5       H  u  pX   nU(       a    OX	 M     U(       a   US   (       d  US	 U(       a  US   (       d  M  U R                  U   S-
  nUS:X  a)  U R                  U	 U R                  R                  U5        OXR                  U'   U R                  U 5        g s  snf )NFrv   rH   r   )rA   rR   rS   r   rV   rT   reversedr   r5   remove_extendorr+   )r#   rX   rY   r8   rZ   r[   r\   r]   r^   r_   lookupsr`   ra   oldcomprb   s                   r%   rQ   BaseAdapterRegistry.unregisterx  sW   JA4Q7JKH..CL ^
$ Aq!AyNNJ?+J  nnT";C$4 $G,G - '"+BK '"++NN8$q(6x(NN**84'(NN8$T[ Ks   Ec                    [        U Vs/ s H  n[        U5      PM     sn5      nSn[        U5      nU R                  n[        U5      U::  a0  UR	                  U R                  5       5        [        U5      U::  a  M0  Xv   nX4-   n	U	 H-  n
UR                  U
5      nUc  U R                  5       nXU
'   UnM/     U R                  UR                  U5      U5      X'   UbN  U R                  R                  US5      S-   nXR                  U'   US:X  a  U R                  R                  U5        U R                  U 5        g s  snf )N r   rH   )rA   rR   rS   r   rT   rU   rV   r>   r   r5   rW   r+   )r#   rX   rY   rZ   r[   r8   r\   r]   r^   r_   r`   ra   rb   s                r%   	subscribeBaseAdapterRegistry.subscribe  s)   JA4Q7JKH##'le#NN4,,./ 'le#^
$Aq!Ay%%' !1J   //
t0DeL
""8Q/!3A'(NN8$Av++H5T1 Ks   E c                 b    U R                  U R                  UUS5      =(       d    SnX4;   a  U$ S $ )Nr   r;   )rf   r   )r#   rX   rY   
subscriberr   s        r%   
subscribedBaseAdapterRegistry.subscribed  sA    oo	
 
  	 (6z@D@r(   c              #   t   #    U R                  U R                  5       H  u  pp4U H	  nXU4v   M     M     g7f)a  
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)rx   r   )r#   rX   rY   _namerZ   rC   s         r%   allSubscriptions$BaseAdapterRegistry.allSubscriptions  sA      150A0A1
,H 1-- 1
s   68c                 L   [        U Vs/ s H  n[        U5      PM     sn5      n[        U5      nU R                  nU[        U5      :  a  g Xe   nX4-   n/ n	U H-  n
UR	                  U
5      nUc    g U	R                  Xz45        UnM/     UR	                  S5      nU(       d  g [        U5      nUc  SnOU R                  X5      nA[        U5      U:X  a  g U(       a  XS'   OMUS	 [        U	5       H  u  pX   nU(       a    OX	 M     U(       a   US   (       d  US	 U(       a  US   (       d  M  Ub\  U R                  U   [        U5      -   U-
  nUS:X  a)  U R                  U	 U R                  R                  U5        OUU R                  U'   U R                  U 5        g s  snf )Nr   r;   rv   r   )rA   rR   rS   r   rV   rT   rD   r~   r   r5   r   r+   )r#   rX   rY   rZ   r[   r\   r]   r^   r_   r   r`   ra   r   len_oldnewr   rb   s                    r%   unsubscribeBaseAdapterRegistry.unsubscribe  s   JA4Q7JKH##CL ^
$ Aq!AyNNJ?+J  nnR c(=
 C++C7C s8w rN 2#G,G - '"+BK '"++ x(3s83g=AAvNN8,..x8+,x(TE Ks   F!c                     U R                  5       nU R                  5       nS nU" U5      nU" U5      nU R                  U R                  5        U H  nU R                  " U6   M     U H  nU R
                  " U6   M     g)a  
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                      [        U 5      n[        R                  " U4U 5      $ ! [         a    [        S5      s $ f = fNr;   )nextStopIterationiter	itertoolschain)itfirsts     r%   buffer+BaseAdapterRegistry.rebuild.<locals>.buffer8  s?     R ??E8R00 !  Bx s   % ==N)r{   r   r&   r!   rc   r   )r#   registrationsr   r   argss        r%   rebuildBaseAdapterRegistry.rebuild"  s}    & --/--/		1 }-}- 	dnn% "DMM4  " "DNND! "r(   c                      " S S5      nU$ )Nc                       \ rS rSr0 rSrg)2BaseAdapterRegistry.get.<locals>.XXXTwistedFakeOutiZ  r;   N)__name__
__module____qualname____firstlineno__selfImplied__static_attributes__r;   r(   r%   XXXTwistedFakeOutr   Z  s    Kr(   r   r;   )r#   _r   s      r%   rV   BaseAdapterRegistry.getY  s    	 	  r(   )r!   r   r   r   r5   r   r;   r   r   )%r   r   r   r   __doc__r6   rI   r&   r,   propertyr!   r    listr   rA   _leafSequenceTypedictrU   r   r>   rD   r+   rc   rf   ri   classmethodrm   rx   r{   rQ   r   r   r   r   r   rV   r   r;   r(   r%   r   r   @   s    ;|2J K-^	 @BI@ MLM44L83!F$,
 @ @8$5.`6A."CJ3"n!r(   r   c                   l   ^  \ rS rSrS rSS jrS rSS jrSS jrSS jr	SU 4S jjr
S	 rS
 rSrU =r$ )
LookupBaseib  c                 .    0 U l         0 U l        0 U l        g r   _cache_mcache_scacher/   s    r%   r&   LookupBase.__init__e  s    r(   c                     U R                   R                  5         U R                  R                  5         U R                  R                  5         g r   )r   clearr   r   )r#   ignoreds     r%   r+   LookupBase.changedj  s2    r(   c                     U R                   R                  U5      nUc  0 nX0R                   U'   U(       a  UR                  U5      nUc  0 nXCU'   UnU$ r   )r   rV   )r#   rY   r8   cachecs        r%   	_getcacheLookupBase._getcacheo  sU    )=E$)KK!		$AydEr(   c                    [        U[        5      (       d  [        S5      eU R                  X#5      n[	        U5      n[        U5      S:X  a  UR                  US   [        5      nOUR                  [	        U5      [        5      nU[        L a6  U R                  XU5      n[        U5      S:X  a  XeUS   '   OXe[	        U5      '   Uc  U$ U$ )NrM   rH   r   )	rN   rO   rP   r   rA   rS   rV   _not_in_mapping_uncached_lookupr#   rX   rY   r8   defaultr   results          r%   r   LookupBase.lookup|  s    $$$344x.?x=AYYx{O<FYYuX@F_$**8tDF8}!%+hqk")/eHo&>Nr(   c                     [        U[        5      (       d  [        S5      eU R                  X#5      nUR	                  U[
        5      nU[
        L a  U R                  U4X#U5      $ Uc  U$ U$ NrM   )rN   rO   rP   r   rV   r   r   r   s          r%   r   LookupBase.lookup1  se    $$$344x.8_5_$;;|XWEE>Nr(   c                 &    U R                  X!X45      $ r   )r   )r#   objectrY   r8   r   s        r%   r   LookupBase.queryAdapter  s      4AAr(   c                 F  > [        U[        5      (       d  [        S5      e[        U5      nU R	                  X5      nUR                  U[        5      nU[        L a  U R                  U4X5      nUb.  [        U[        5      (       a  UR                  nU" U5      nUb  U$ U$ r   )
rN   rO   rP   r   r   rV   r   r   super__self__)
r#   rY   r   r8   r   rX   r   factoryr   	__class__s
            r%   r   LookupBase.adapter_hook  s    $$$344f%x.))Ho6o%kk8,?G&%((V_F!r(   c                     U R                   R                  U5      nUc  0 nX0R                   U'   [        U5      nUR                  U[        5      nU[        L a  U R	                  X5      nXCU'   U$ r   )r   rV   rA   r   _uncached_lookupAllr#   rX   rY   r   r   s        r%   r   LookupBase.lookupAll  si      *=E%*LL"?8_5_$--hAF$(Or(   c                     U R                   R                  U5      nUc  0 nX0R                   U'   [        U5      nUR                  U[        5      nU[        L a  U R	                  X5      nXCU'   U$ r   )r   rV   rA   r   _uncached_subscriptionsr   s        r%   r   LookupBase.subscriptions  si      *=E%*LL"?8_5_$11(EF$(Or(   r   r   r   N)r   r   r   r   r&   r+   r   r   r   r   r   r   r   r   __classcell__r   s   @r%   r   r   b  s6    

,B$ r(   r   c                   2    \ rS rSrS rS rS rS rS rSr	g)	VerifyingBasei  c                     [         R                  X5        U R                  R                  SS  U l        U R                   Vs/ s H  o"R
                  PM     snU l        g s  snf rG   )LookupBaseFallbackr+   	_registryr   
_verify_rorI   _verify_generations)r#   rJ   r[   s      r%   r+   VerifyingBase.changed  sH    ""4<..++AB/;???#K?aMM?#K #Ks   A c                     U R                    Vs/ s H  oR                  PM     snU R                  :w  a  U R                  S 5        g g s  snf r   )r   rI   r   r+   r#   r[   s     r%   _verifyVerifyingBase._verify  sG     (,'6!))* LL	* s   Ac                 N    U R                  5         [        R                  XU5      $ r   )r   r   r   )r#   rY   r8   s      r%   r   VerifyingBase._getcache  s#    !++D
 	
r(   c                 N    U R                  5         [        R                  XU5      $ r   )r   r   r   r#   rX   rY   s      r%   r   VerifyingBase.lookupAll  s#    !++H
 	
r(   c                 N    U R                  5         [        R                  XU5      $ r   )r   r   r   r   s      r%   r   VerifyingBase.subscriptions  s#    !//H
 	
r(   )r   r   N)
r   r   r   r   r+   r   r   r   r   r   r;   r(   r%   r   r     s    L



r(   r   c                      ^  \ rS rSrU 4S jrSU 4S jjrS rS rS rS r	SS jr
SU 4S	 jjrS
 rS rS rS rSrU =r$ )AdapterLookupBasei  c                 \   > Xl         0 U l        U R                  5         [        TU ]  5         g r   )r   	_requiredinit_extendorsr   r&   )r#   registryr   s     r%   r&   AdapterLookupBase.__init__  s&    !r(   c                    > [         TU ]  S 5        U R                  R                  5        H   nU" 5       nUc  M  UR	                  U 5        M"     U R                  R                  5         g r   )r   r+   r   keysr   r   )r#   r   r[   r   s      r%   r+   AdapterLookupBase.changed   sP    $$&AA}d# ' 	r(   c                 n    0 U l         U R                  R                   H  nU R                  U5        M     g r   )
_extendorsr   r   rW   )r#   ps     r%   r    AdapterLookupBase.init_extendors  s+    ))Aa  *r(   c                 0   U R                   nUR                   Hp  nUR                  US5      nU Vs/ s H  oQR                  U5      (       d  M  UPM     snU/-   U Vs/ s H  oQR                  U5      (       a  M  UPM     sn-   X#'   Mr     g s  snf s  snf r   )r  __iro__rV   isOrExtends)r#   rY   r  ro   	extendorses         r%   rW   AdapterLookupBase.add_extendor#  s    __
!!A"q"-I  )(!,@,@,CAy 
  )(!0D0DQ0GAy	 M "s   BBB<Bc                     U R                   nUR                   H/  nUR                  US5       Vs/ s H  nXA:w  d  M
  UPM     snX#'   M1     g s  snf r   )r  r	  rV   )r#   rY   r  ro   r  s        r%   r   !AdapterLookupBase.remove_extendor1  sO    __
!!A(2q"(= /(=1 ! (= /JM "/s
   	AAc                     U R                   nU H/  nUR                  5       nXB;  d  M  UR                  U 5        SX$'   M1     g rG   )r   weakrefr   )r#   rX   _refsr[   refs        r%   
_subscribeAdapterLookupBase._subscribe7  s9    A))+CD!
	 r(   c           	      R   [        U5      nS n[        U5      nU R                  R                   He  nUR                  nU[        U5      :  a  M   UR
                  R                  R                  U5      nU(       d  MN  Xu   n	[        XXSU5      nUc  Me    O   U R                  " U6   U$ Nr   )
rA   rS   r   r   r   r5   r  rV   _lookupr  )
r#   rX   rY   r8   r   r\   r   r]   r  r^   s
             r%   r   "AdapterLookupBase._uncached_lookup?  s    ?H))H((GG$ **5599(CI JZ9A"$F! * 	"r(   c           	         > U R                  U Vs/ s H  n[        U5      PM     snX#5      nUc  U$ U" U Vs/ s H&  n[        U[        5      (       a  UR                  OUPM(     sn6 nUc  U$ U$ s  snf s  snf r   )r   r   rN   r   r   )	r#   objectsrY   r8   r   or   r   r   s	           r%   r   #AdapterLookupBase.queryMultiAdapterV  s    ++g>gz!}g>O?N?F
?F!*Q..AJJA5w
  >N ?
s
   A1-A6c           	         [        U5      n[        U5      n0 n[        U R                  R                  5       H`  nUR
                  nU[        U5      :  a  M   UR                  R                  R                  U5      nU(       d  MN  Xc   n[        XXtSU5        Mb     U R                  " U6   [        UR                  5       5      $ r  )rA   rS   r~   r   r   r   r5   r  rV   
_lookupAllr  rl   )	r#   rX   rY   r\   r   r   r]   r  r^   s	            r%   r   %AdapterLookupBase._uncached_lookupAllc  s    ?H !2!23H((GG$ **5599(CI JzY5I 4 	"V\\^$$r(   c                 T    U R                  X5       Vs/ s H  o3S   PM	     sn$ s  snf r  )r   )r#   rX   rY   r   s       r%   r   AdapterLookupBase.namesu  s'    "nnX@A@!@AAAs   %c           
      `   [        U5      n[        U5      n/ n[        U R                  R                  5       Hc  nUR
                  nU[        U5      :  a  M   Uc  U4nO*UR                  R                  R                  U5      nUc  MQ  [        Xc   XSUSU5        Me     U R                  " U6   U$ )Nr   r   )rA   rS   r~   r   r   r   r5   r  rV   _subscriptionsr  )r#   rX   rY   r\   r   r   r]   r  s           r%   r   )AdapterLookupBase._uncached_subscriptionsx  s    ?H !2!23H++GG$%L	$..99==hG	$7>8!1e- 4 	"r(   c                     U R                  U Vs/ s H  n[        U5      PM     snU5      nUc  SnU H  nU" U6   M
     U$ / nU H  nU" U6 nUc  M  UR                  U5        M      U$ s  snf r   )r   r   rT   )r#   r  rY   r  r   r   subscriptionr   s           r%   r   AdapterLookupBase.subscribers  s    **$+,GqZ]G,h
 F -g& !.  F -)73
)MM*- !.  -s   A*)r  r   r   r   r   r   )r   r   r   r   r&   r+   r   rW   r   r  r   r   r   r   r   r   r   r   r   s   @r%   r   r     sE    <!
/.%$B. r(   r   c                       \ rS rSrSrg)AdapterLookupi  r;   Nr   r   r   r   r   r;   r(   r%   r*  r*        r(   r*  c                   X   ^  \ rS rSrSr\rS	U 4S jjrS rS r	U 4S jr
U 4S jrSrU =r$ )
r   i  zU
A full implementation of ``IAdapterRegistry`` that adds support for
sub-registries.
c                 X   > [         R                  " 5       U l        [        TU ]  U5        g r   )r  WeakKeyDictionary_v_subregistriesr   r&   )r#   r$   r   s     r%   r&   AdapterRegistry.__init__  s#     !( 9 9 ;r(   c                 "    SU R                   U'   g rG   r0  r   s     r%   _addSubregistryAdapterRegistry._addSubregistry  s    #$a r(   c                 >    XR                   ;   a  U R                   U	 g g r   r3  r   s     r%   _removeSubregistry"AdapterRegistry._removeSubregistry  s!    %%%%%a( &r(   c                    > U R                   R                  SS5      nU H  nX1;  d  M
  UR                  U 5        M     U H  nX2;  d  M
  UR                  U 5        M     [        TU ]  U5        g )Nr!   r;   )r*   rV   r7  r4  r   r,   )r#   r$   r   r[   r   s       r%   r,   AdapterRegistry._setBases  sd    mmR0A~$$T*  A|!!$'  	% r(   c                    > [         TU ]  U5        U R                  R                  5        H  nUR                  U5        M     g r   )r   r+   r0  r  )r#   rJ   subr   s      r%   r+   AdapterRegistry.changed  s6    *+((--/CKK*+ 0r(   r3  r   )r   r   r   r   r   r*  r4   r&   r4  r7  r,   r+   r   r   r   s   @r%   r   r     s-    
  K %)	!, ,r(   c                       \ rS rSrSrg)VerifyingAdapterLookupi  r;   Nr+  r;   r(   r%   r?  r?    r,  r(   r?  c                       \ rS rSrSr\rSrg)r   i  z*
The most commonly-used adapter registry.
r;   N)r   r   r   r   r   r?  r4   r   r;   r(   r%   r   r     s     )Kr(   c                     U c  [         $ U $ r   r   )xs    r%   rR   rR     s    yr(   c           	         U R                   nXE:  a?  X   R                   H,  nU" U5      nU(       d  M  [        XX#US-   U5      n	U	c  M*  U	s  $    g U H,  n
U" U
5      nU(       d  M  UR                  U5      n	U	c  M*  U	s  $    g rG   )rV   __sro__r  )r^   specsrY   r8   ro   lcomponents_getspeccompsr[   ifaces              r%   r  r    s    
  ^^NuH$$D"4(EuE(!a%C=H %  E"5)EuIIdO=H  r(   c           	         U R                   nXE:  aA  [        X   R                  5       H%  nU" U5      nU(       d  M  [        XX#US-   U5        M'     g [        U5       H%  n	U" U	5      nU(       d  M  UR	                  U5        M'     g rG   )rV   r~   rD  r  update)
r^   rE  rY   r   ro   rF  rG  rH  rI  rJ  s
             r%   r  r    st    ^^NuUX--.D"4(Eu51q5!D /
 h'E"5)Eue$ (r(   c           
      D   U R                   nXV:  aA  [        X   R                  5       H%  nU" U5      n	U	(       d  M  [        XX#XES-   U5        M'     g [        U5       H?  n
U" U
5      n	U	(       d  M  U	R                  U5      n	U	(       d  M.  UR	                  U	5        MA     g rG   )rV   r~   rD  r$  extend)r^   rE  rY   r8   r   ro   rF  rG  rH  rI  rJ  s              r%   r$  r$    s      ^^NuUX--.D"4(Eu(&a% / h'E"5)Eu		$5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   rR   r  r  r$  r;   r(   r%   <module>rS     s	     $ & %  2 . 6 H\! \!~ ( k k k\ #
& #
 #
Le eP	%z 	 %,) %, %,P	. 	 )2 ) )0%)r(   