o ,W@s dZdZddlZddlZzddlmZWn ey!ddZYnwddlmZddl m Z dd l m Z Gd d d e Z Gd d d ejZeZdddZddZejddZdddZdddZddZddZeZzddlmZWn ey~YdSweedS) zEHooks for getting and setting a site in the thread global namespace. restructuredtextN)removeSecurityProxycCs|SN)xrr6/usr/lib/python3/dist-packages/zope/component/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 ||_dSrfunc)selfr rrr__init__&s zread_property.__init__cCs|dur|S||Srr )rinstclsrrr__get__)s zread_property.__get__N)__name__ __module__ __qualname____doc__rrrrrrr s r c@s"eZdZdZeZeddZdS)SiteInfoNcCs|jjj}||_|Sr)smadapters adapter_hook)rrrrrr3s zSiteInfo.adapter_hook)rrrsiterrr rrrrrr/s rcCsL|durt}nt|}|}|t_|t_zt`WdSty%YdSwr)rrgetSiteManagersiteinforrrAttributeError)rrrrrsetSite;s   rcCstjSr)rrrrrrgetSiteRsr ccs0t}t|z dVWt|dSt|wr)r r)rold_siterrrrVs rcCs&|durtjSt|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)rrr rr)contextrrrrr`srcCs*z t||||WSty|YSwr)rrr ) interfaceobjectnamedefaultrrrrus  rcCs(ddlm}|jt|jtdSNr_api)zope.componentr*rsethookrr)rrrsetHooks|s  r-cCs@ddlm}|j|jzt`WdStyYdSwr()r+r*rresetrrrr)rrr resetHookss     r/) addCleanUpr)r#N)r __docformat__ contextlib threadingzope.security.proxyr ImportErrorzope.component.globalregistryrzope.component.interfacesr r r%r localrrrr contextmanagerrrrr-r/ clearSitezope.testing.cleanupr0rrrrs<