File: //usr/lib/python3.9/site-packages/ipalib/__pycache__/backend.cpython-39.opt-1.pyc
a
}�fl � @ s� d Z ddlZddlZddlZddlmZ ddlmZmZm Z ddl
mZmZm
Z
e�e�ZG dd� dej�ZG dd � d e�ZG d
d� de�ZdS )z*
Base classes for all backed-end plugins.
� N)�plugable)�PublicError�
InternalError�CommandError)�context�
Connection�destroy_contextc @ s e Zd ZdZdS )�Backendz-
Base class for all backend plugins.
N)�__name__�
__module__�__qualname__�__doc__� r r �2/usr/lib/python3.9/site-packages/ipalib/backend.pyr # s r c @ sR e Zd ZdZddd�Zdd� Zdd� Zd d
� Zdd� Zd
d� Z dd� Z
ee
�ZdS )�Connectiblea$
Base class for backend plugins that create connections.
In addition to the nicety of providing a standard connection API, all
backend plugins that create connections should use this base class so that
`request.destroy_context()` can properly close all open connections.
Fc C s6 t �| |� |r| j| _nd| jtt| ��f | _d S )Nz%s_%s)r �__init__�name�id�str)�selfZapiZshared_instancer r r r 2 s
zConnectible.__init__c O s` t t| j�r(td�| j| jt�� j���| j|i |��}t t| jt
|| j�� t�
d| j� dS )z1
Create thread-local connection.
z%{0} is already connected ({1} in {2})zCreated connection context.%sN)�hasattrr r � Exception�formatr � threading�current_thread�create_connection�setattrr �
disconnect�logger�debug)r �args�kw�connr r r �connect9 s ��zConnectible.connectc O s t d| j ��d S )Nz%s.create_connection()��NotImplementedErrorr )r r r! r r r r J s zConnectible.create_connectionc C sN t t| j�s(td�| j| jt�� j���| �� t t| j� t
�d| j� d S )N�!{0} is not connected ({1} in {2})zDestroyed connection context.%s)r r r r r r r r �destroy_connection�delattrr r �r r r r r M s ��zConnectible.disconnectc C s t d| j ��d S )Nz%s.destroy_connection()r$ r) r r r r'