3 ,W@sdZdZddlZddlZyddlmZWnek rDddZYnXddlmZddl m Z dd l m Z Gd d d e Z Gd d d ejZeZdddZddZejddZdddZd ddZddZddZeZyddlmZWnek rYn XeedS)!zEHooks for getting and setting a site in the thread global namespace. ZrestructuredtextN)removeSecurityProxycCs|S)N)xrr/usr/lib/python3.6/hooks.pyrsr)getGlobalSiteManager)ComponentLookupError)IComponentLookupc@s eZdZdZddZddZdS) read_propertyzDescriptor for property-like computed attributes. Unlike the standard 'property', this descriptor allows assigning a value to the instance, shadowing the property getter function. cCs ||_dS)N)func)selfr rrr__init__&szread_property.__init__cCs|dkr |S|j|S)N)r )r Zinstclsrrr__get__)szread_property.__get__N)__name__ __module__ __qualname____doc__r rrrrrr sr c@s"eZdZdZeZeddZdS)SiteInfoNcCs|jjj}||_|S)N)smZadapters adapter_hook)r rrrrr3s zSiteInfo.adapter_hook)rrrsiterrr rrrrrr/src CsN|dkrt}nt|}|j}|t_|t_yt`Wntk rHYnXdS)N)rrgetSiteManagersiteinforrrAttributeError)rrrrrsetSite;s rcCstjS)N)rrrrrrgetSiteRsrc cs(t}t|z dVWdt|XdS)N)rr)rZold_siterrrrVs  rcCs&|dkrtjSt|t}t|}|S)zA special hook for getting the site manager. Here we take the currently set site into account to find the appropriate site manager. N)rrrrr)contextrrrrr`s  rc Cs*ytj||||Stk r$|SXdS)N)rrr)Z interfaceobjectnamedefaultrrrrusrcCs(ddlm}|jjt|jjtdS)Nr)_api)zope.componentr!rZsethookr)r!rrrsetHooks|s  r#c CsBddlm}|jj|jjyt`Wntk r<YnXdS)Nr)r!)r"r!rresetrrr)r!rrr resetHookss   r%) addCleanUp)N)N)rN)rZ __docformat__ contextlibZ threadingZzope.security.proxyr ImportErrorZzope.component.globalregistryrZzope.component.interfacesrrrr Zlocalrrrrcontextmanagerrrrr#r%Z clearSiteZzope.testing.cleanupr&rrrrs4