
6j/Qc           @   sk  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
 l m Z d d l m Z d d l m Z d d l m Z d d l m Z y d d l m Z Wn! e k
 rd d l m Z n Xd a e d d   Z d   Z d d  Z e e d d  Z e e d d d  Z e e d d  Z e e d d d  Z d d  Z  d d  Z! d   Z" e d d d   Z# d d l$ Z% e% j& j& j' j( e#  d d d  Z) d d d d  Z* d d  Z+ d d  Z, e-   Z. d d d   Z/ d d!  Z0 d"   Z1 d d#  Z2 d d$  Z3 d S(%   s   Zope 3 Component Architecture
iN(   t	   Interface(   t   implementedBy(   t
   providedBy(   t   IComponentArchitecture(   t!   IComponentRegistrationConvenience(   t   IFactory(   t   ComponentLookupError(   t   IComponentLookup(   t   _BLANK(   t	   adaptedBy(   t   adapter(   t   adapts(   t   hookablec         C   sf   |  d k r/ t d k r+ d d l m a n  t Sy t |   SWn" t k
 ra } t | j    n Xd S(   s!    See IComponentArchitecture.
    i(   t   baseN(   t   NoneR   t   zope.component.globalregistryR   t	   TypeErrorR   t   args(   t   contextt   error(    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyt   getSiteManager,   s    c         C   s4   t  |  | |  } | d  k r0 t |  |   n  | S(   N(   t   queryAdapterInContextR   R   (   t   objectt	   interfaceR   R
   (    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyt   getAdapterInContext?   s    c         C   s   t  |  d d   } | d  k	 rt y | |  } Wn0 t k
 r` t j   d j d  k	 rq   qq qt X| d  k	 rt | Sn  | j |   r |  St |  j |  | d |  S(   Nt   __conform__i   t    (	   t   getattrR   R   t   syst   exc_infot   tb_nextR   R   t   queryAdapter(   R   R   R   t   defaultt   conformR
   (    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyR   E   s    
c         C   s=   t  |  | | d  |  } | d  k r9 t |  | |   n  | S(   N(   R   R   R   (   R   R   t   nameR   R
   (    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyt
   getAdapter`   s    c         C   s;   | d  k r t | |  | |  St |  j |  | | |  S(   N(   R   t   adapter_hookR   R   (   R   R   R"   R    R   (    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyR   f   s    c         C   s=   t  |  | | d | } | d  k r9 t |  | |   n  | S(   NR   (   t   queryMultiAdapterR   R   (   t   objectsR   R"   R   R
   (    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyt   getMultiAdapterm   s    c         C   s;   y t  |  } Wn t k
 r$ | SX| j |  | | |  S(   N(   R   R   R%   (   R&   R   R"   R    R   t   sitemanager(    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyR%   s   s
    c         C   s5   y t  |  } Wn t k
 r$ g  SX| j |  |  S(   N(   R   R   t   getAdapters(   R&   t   providedR   R(   (    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyR)   }   s
    c         C   s5   y t  |  } Wn t k
 r$ g  SX| j |  |  S(   N(   R   R   t   subscribers(   R&   R   R   R(   (    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyR+      s
    c          G   s   t  d   j |  d   d  S(   N(   R   R   R+   (   R&   (    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyt   handle   s    R   c         C   s8   y t    } Wn t k
 r! d  SX| j | |  | |  S(   N(   R   R   R   R   (   R   R   R"   R    R(   (    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyR$      s
    c         C   s8   t  |  | d | } | d  k	 r% | St |  |   d  S(   NR   (   t   queryUtilityR   R   (   R   R"   R   t   utility(    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyt
   getUtility   s    c         C   s   t  |  j |  | |  S(   N(   R   R-   (   R   R"   R    R   (    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyR-      s    c         C   s   t  |  j |   S(   N(   R   t   getUtilitiesFor(   R   R   (    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyR0      s    c         C   s   t  |  j |   S(   N(   R   t   getAllUtilitiesRegisteredFor(   R   R   (    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyR1      s    c         C   sh   y t  |   } Wn t k
 r$ | SX| j } x3 | D]+ } | j | | t  } | t k	 r5 | Sq5 W| S(   s   Query for the next available utility.

    Find the next available utility providing `interface` and having the
    specified name. If no utility was found, return the specified `default`
    value.
    (   R   R   t	   __bases__R-   t   _marker(   R   R   R"   R    t   smt   basesR   t   util(    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyt   queryNextUtility   s    	c         C   sG   t  |  | | t  } | t k rC t j j j d | | f   n  | S(   sf   Get the next available utility.

    If no utility was found, a `ComponentLookupError` is raised.
    s/   No more utilities for %s, '%s' have been found.(   R7   R3   t   zopet	   componentt
   interfacesR   (   R   R   R"   R6   (    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyt   getNextUtility   s    c         O   s+   | j  d d  } t t |  |  | |   S(   sk   Invoke the named factory and return the result.

    ``__factory_name`` is a positional-only argument.
    R   N(   t   popR   R/   R   (   t   __factory_nameR   t   kwargsR   (    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyt   createObject   s    c         C   s   t  t |  |  j   S(   sn   Return the interface provided by the named factory's objects

    Result might be a single interface. XXX
    (   R/   R   t   getInterfaces(   R"   R   (    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyt   getFactoryInterfaces   s    c         c   s   t  |  } x | j t  D]| \ } } | j   } y! | j |   rT | | f Vn  Wq t k
 r x0 | D]$ } | j |   rl | | f VPql ql Wq Xq Wd S(   sC   Return info on all factories implementing the given interface.
    N(   R   R0   R   R@   t   isOrExtendst   AttributeError(   R   R   t   utilsR"   t   factoryR:   t   iface(    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyt   getFactoriesFor   s    (4   t   __doc__R   t   typest   zope.interfaceR    R   R   t   zope.component.interfacesR   R   R   R   R   t   zope.component._compatR   t   zope.component._declarationR	   R
   R   t   zope.hookableR   t   ImportErrort   zope.component.hookableR   R   R   R   R   R#   R   R'   R%   R)   R+   R,   R$   t   zope.interface.interfaceR8   R   t   adapter_hookst   appendR/   R-   R0   R1   R   R3   R7   R;   R?   RA   RG   (    (    (    s7   /usr/lib/python2.7/site-packages/zope/component/_api.pyt   <module>   s\   							