File: //usr/lib/python3.9/site-packages/ipalib/__pycache__/backend.cpython-39.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 sn t t| j�r(td�| j| jt�� j���| j|i |��}t t| jt
|| j�� | j|u s\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�conn�logger�debug)r �args�kwr r r r �connect9 s ��zConnectible.connectc O s t d| j ��d S )Nz%s.create_connection()��NotImplementedErrorr )r r! r"