o
    ,ò¿W)  ã                   @   s¶   d 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ZG dd„ deƒZdd„ Zddd„Zdd„ Zdd„ ZdS )z5zope.security support for the configuration handlers
é    )Ú
providedBy)Ú	ProxyBase)ÚgetProxiedObject)ÚLocatingTrustedAdapterFactory)ÚLocatingUntrustedAdapterFactory)ÚTrustedAdapterFactory)ÚChecker)ÚCheckerPublic)ÚInterfaceChecker)ÚProxyzzope.Publicc                   @   s    e Zd ZdZdd„ ZeeƒZdS )ÚPermissionProxy)Ú__Security_checker__c                 C   s   t t| ƒƒS ©N)r   r   )Úself© r   ú9/usr/lib/python3/dist-packages/zope/component/security.pyÚ__providedBy__"   s   zPermissionProxy.__providedBy__N)Ú__name__Ú
__module__Ú__qualname__Ú	__slots__r   Úpropertyr   r   r   r   r      s    r   c                 C   sh   |s|sdg}|t krt}i }|r|D ]}|||< q|r.|D ]}|jddD ]}|||< q&qt|ƒ}|S )NÚ__call__T)Úall)ÚPublicPermissionr	   Únamesr   )Ú_contextÚ
permissionÚallowed_interfaceÚallowed_attributesÚrequireÚnameÚiÚcheckerr   r   r   Ú_checker&   s   

ÿr$   Nc                 C   sH   |du r|du s|du rt dƒ‚|tkrt}t||ƒ}t| ƒ} || _| S )zˆTry to get the object proxied with the `checker`, but not too soon

    We really don't want to proxy the object unless we need to.
    Nz<Required arguments: checker or both provides and permissions)Ú
ValueErrorr   r	   r
   r   r   )Úobr#   Úprovidesr   r   r   r   Úproxify9   s   
r(   c                    s.   |t krt}t||ƒ‰ ‡ ‡fdd„}ˆ|_|S )Nc                     s4   ˆ| Ž }zˆ |_ W |S  ty   t|ˆ ƒ}Y |S w r   )r   ÚAttributeErrorr   )Úargsr&   ©r#   Úoriginal_factoryr   r   ÚfactoryO   s   þþz!protectedFactory.<locals>.factory)r   r	   r
   r-   )r,   r'   r   r-   r   r+   r   ÚprotectedFactoryJ   s   
r.   c                 C   sD   |t krt}|s|d ur|tur|rt| ƒS t| ƒS |r t| ƒS | S r   )r   r	   r   r   r   )r-   r   ÚlocateÚtrustedr   r   r   ÚsecurityAdapterFactoryY   s   r1   )NNN)Ú__doc__Úzope.interfacer   Ú
zope.proxyr   r   Úzope.security.adapterr   r   r   Úzope.security.checkerr   r	   r
   Úzope.security.proxyr   r   r   r$   r(   r.   r1   r   r   r   r   Ú<module>   s"   
