B
    `	                 @   s\   d dl Z d dlmZ G dd de jZdd ZeedZdd	 Zdd
dZG dd dZ	dS )    N)global_registryc               @   s:   e Zd ZdddZdd ZeZdd Zdd	 Zd
d ZdS )ThreadLocalManagerNc             C   s   g | _ || _d S )N)stackdefault)selfr    r   [/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/pyramid/threadlocal.py__init__   s    zThreadLocalManager.__init__c             C   s   | j | d S )N)r   append)r   infor   r   r   push   s    zThreadLocalManager.pushc             C   s   | j r| j  S d S )N)r   pop)r   r   r   r   r      s    zThreadLocalManager.popc             C   s(   y
| j d S  tk
r"   |  S X d S )N)r   
IndexErrorr   )r   r   r   r   get   s    
zThreadLocalManager.getc             C   s   g | j d d < d S )N)r   )r   r   r   r   clear   s    zThreadLocalManager.clear)N)	__name__
__module____qualname__r	   r   setr   r   r   r   r   r   r   r      s   
	r   c               C   s
   d t dS )N)requestregistry)r   r   r   r   r   defaults#   s    r   )r   c               C   s   t  d S )a  
    Return the currently active request or ``None`` if no request
    is currently active.

    This function should be used *extremely sparingly*, usually only
    in unit testing code.  It's almost always usually a mistake to use
    ``get_current_request`` outside a testing context because its
    usage makes it possible to write code that can be neither easily
    tested nor scripted.

    r   )managerr   r   r   r   r   get_current_request*   s    r   c             C   s   t  d S )a  
    Return the currently active :term:`application registry` or the
    global application registry if no request is currently active.

    This function should be used *extremely sparingly*, usually only
    in unit testing code.  It's almost always usually a mistake to use
    ``get_current_registry`` outside a testing context because its
    usage makes it possible to write code that can be neither easily
    tested nor scripted.

    r   )r   r   )contextr   r   r   get_current_registry9   s    r   c               @   s4   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZdS )RequestContextc             C   s
   || _ d S )N)r   )r   r   r   r   r   r	   K   s    zRequestContext.__init__c             C   s    | j }|j}t||d |S )N)r   r   )r   r   r   r   )r   r   r   r   r   r   beginN   s    zRequestContext.beginc             C   s   t   d S )N)r   r   )r   r   r   r   endT   s    zRequestContext.endc             C   s   |   S )N)r   )r   r   r   r   	__enter__W   s    zRequestContext.__enter__c             G   s   |    d S )N)r   )r   argsr   r   r   __exit__Z   s    zRequestContext.__exit__N)r   r   r   r	   r   r   r    r"   r   r   r   r   r   J   s
   r   )N)
	threadingZpyramid.registryr   localr   r   r   r   r   r   r   r   r   r   <module>   s   

