ó
6j/Qc           @   sM  d  Z  d Z d d l Z d d l Z y d d l m Z Wn e k
 rT d   Z n Xd d l m Z d d l	 m
 Z
 d d l	 m Z d	 e f d
     YZ d e j f d     YZ e   Z d d  Z d   Z e j d    Z d d  Z d d d  Z d   Z d   Z e Z y d d l m Z Wn e k
 r>n Xe e  d S(   sE   Hooks for getting and setting a site in the thread global namespace.
t   restructuredtexti˙˙˙˙N(   t   removeSecurityProxyc         C   s   |  S(   N(    (   t   x(    (    s8   /usr/lib/python2.7/site-packages/zope/component/hooks.pyR      s    (   t   getGlobalSiteManager(   t   ComponentLookupError(   t   IComponentLookupt   read_propertyc           B   s    e  Z d  Z d   Z d   Z RS(   sÁ   Descriptor for property-like computed attributes.

    Unlike the standard 'property', this descriptor allows assigning a
    value to the instance, shadowing the property getter function.
    c         C   s   | |  _  d  S(   N(   t   func(   t   selfR   (    (    s8   /usr/lib/python2.7/site-packages/zope/component/hooks.pyt   __init__&   s    c         C   s   | d  k r |  S|  j |  S(   N(   t   NoneR   (   R   t   instt   cls(    (    s8   /usr/lib/python2.7/site-packages/zope/component/hooks.pyt   __get__)   s    (   t   __name__t
   __module__t   __doc__R	   R   (    (    (    s8   /usr/lib/python2.7/site-packages/zope/component/hooks.pyR       s   	t   SiteInfoc           B   s&   e  Z d Z e   Z e d     Z RS(   c         C   s   |  j  j j } | |  _ | S(   N(   t   smt   adapterst   adapter_hook(   R   R   (    (    s8   /usr/lib/python2.7/site-packages/zope/component/hooks.pyR   3   s    	N(   R   R   R
   t   siteR   R   R   R   (    (    (    s8   /usr/lib/python2.7/site-packages/zope/component/hooks.pyR   /   s   	c         C   sd   |  d  k r t   } n t |   }  |  j   } |  t _ | t _ y
 t ` Wn t k
 r_ n Xd  S(   N(	   R
   R   R   t   getSiteManagert   siteinfoR   R   R   t   AttributeError(   R   R   (    (    s8   /usr/lib/python2.7/site-packages/zope/component/hooks.pyt   setSite;   s    
		
c           C   s   t  j S(   N(   R   R   (    (    (    s8   /usr/lib/python2.7/site-packages/zope/component/hooks.pyt   getSiteR   s    c         c   s.   t    } t |   z	 d  VWd  t |  Xd  S(   N(   R   R   (   R   t   old_site(    (    s8   /usr/lib/python2.7/site-packages/zope/component/hooks.pyR   V   s
    	
	c         C   s5   |  d k r t j St |  t    } t |  } | S(   s   A special hook for getting the site manager.

    Here we take the currently set site into account to find the appropriate
    site manager.
    N(   R
   R   R   R   R   R   (   t   contextR   (    (    s8   /usr/lib/python2.7/site-packages/zope/component/hooks.pyR   `   s    t    c         C   s3   y t  j |  | | |  SWn t k
 r. | SXd  S(   N(   R   R   R   (   t	   interfacet   objectt   namet   default(    (    s8   /usr/lib/python2.7/site-packages/zope/component/hooks.pyR   u   s    c          C   s4   d d l  m }  |  j j t  |  j j t  d  S(   Ni˙˙˙˙(   t   _api(   t   zope.componentR"   R   t   sethookR   (   R"   (    (    s8   /usr/lib/python2.7/site-packages/zope/component/hooks.pyt   setHooks|   s    c          C   s.   d d l  m }  |  j j   |  j j   d  S(   Ni˙˙˙˙(   R"   (   R#   R"   R   t   resetR   (   R"   (    (    s8   /usr/lib/python2.7/site-packages/zope/component/hooks.pyt
   resetHooks   s    (   t
   addCleanUp(   R   t   __docformat__t
   contextlibt	   threadingt   zope.security.proxyR   t   ImportErrort   zope.component.globalregistryR   t   zope.component.interfacesR   R   R   R   t   localR   R   R
   R   R   t   contextmanagerR   R   R   R%   R'   t	   clearSitet   zope.testing.cleanupR(   (    (    (    s8   /usr/lib/python2.7/site-packages/zope/component/hooks.pyt   <module>   s4   
		
		