Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/orm/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/orm/__pycache__/scoping.cpython-311.pyc

�

�܋f��@�ddlmZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
dgZGd	�de��Z
e
Z	d
�ZejD]Zee
eee�����d�ZdD]Zee
eee�����d
�ZdD]Zee
eee�����dS)�)�class_mapper)�exc)�Session�)�ScopedRegistry)�ThreadLocalRegistry)�warn�scoped_sessionc�:�eZdZdZdZ	dd�Zd�Zd�Zd�Zdd�Z	dS)	r
ztProvides scoped management of :class:`.Session` objects.

    See :ref:`unitofwork_contextual` for a tutorial.

    Nc�n�||_|rt||��|_dSt|��|_dS)a�Construct a new :class:`.scoped_session`.

        :param session_factory: a factory to create new :class:`.Session`
         instances. This is usually, but not necessarily, an instance
         of :class:`.sessionmaker`.
        :param scopefunc: optional function which defines
         the current scope.   If not passed, the :class:`.scoped_session`
         object assumes "thread-local" scope, and will use
         a Python ``threading.local()`` in order to maintain the current
         :class:`.Session`.  If passed, the function should return
         a hashable token; this token will be used as the key in a
         dictionary in order to store and retrieve the current
         :class:`.Session`.

        N)�session_factoryr�registryr)�selfr
�	scopefuncs   �M/opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/orm/scoping.py�__init__zscoped_session.__init__!s=��  /����	A�*�?�I�F�F�D�M�M�M�/��@�@�D�M�M�M�c���|rV|j���rtjd���|jdi|��}|j�|��|S|���S)a�Return the current :class:`.Session`, creating it
        using the :attr:`.scoped_session.session_factory` if not present.

        :param \**kw: Keyword arguments will be passed to the
         :attr:`.scoped_session.session_factory` callable, if an existing
         :class:`.Session` is not present.  If the :class:`.Session` is present
         and keyword arguments have been passed,
         :exc:`~sqlalchemy.exc.InvalidRequestError` is raised.

        zEScoped session is already present; no new arguments may be specified.N�)r�has�sa_exc�InvalidRequestErrorr
�set)r�kw�sesss   r�__call__zscoped_session.__call__8s���	#��}� � �"�"�
��0�9����
,�t�+�1�1�b�1�1���
�!�!�$�'�'�'����=�=�?�?�"rc��|j���r&|������|j���dS)a�Dispose of the current :class:`.Session`, if present.

        This will first call :meth:`.Session.close` method
        on the current :class:`.Session`, which releases any existing
        transactional/connection resources still being held; transactions
        specifically are rolled back.  The :class:`.Session` is then
        discarded.   Upon next usage within the same scope,
        the :class:`.scoped_session` will produce a new
        :class:`.Session` object.

        N)rr�close�clear)rs r�removezscoped_session.removePsN���=�����	$��M�M�O�O�!�!�#�#�#��
�������rc�z�|j���rtd��|jjdi|��dS)z�reconfigure the :class:`.sessionmaker` used by this
        :class:`.scoped_session`.

        See :meth:`.sessionmaker.configure`.

        ztAt least one scoped session is already present.  configure() can not affect sessions that have already been created.Nr)rrr	r
�	configure)r�kwargss  rr"zscoped_session.configureasU���=�����	��(�
�
�
�	'���&�0�0��0�0�0�0�0rc�F���G��fd�dt��}|��S)a0return a class property which produces a :class:`_query.Query`
        object
        against the class and the current :class:`.Session` when called.

        e.g.::

            Session = scoped_session(sessionmaker())

            class MyClass(object):
                query = Session.query_property()

            # after mappers are defined
            result = MyClass.query.filter(MyClass.name=='foo').all()

        Produces instances of the session's configured query class by
        default.  To override and use a custom implementation, provide
        a ``query_cls`` callable.  The callable will be invoked with
        the class's mapper as a positional argument and a session
        keyword argument.

        There is no limit to the number of query properties placed on
        a class.

        c���eZdZ��fd�ZdS)�,scoped_session.query_property.<locals>.queryc����	t|��}|rH�r�|�������S�����|��SdS#tj$rYdSwxYw)N)�session)rr�query�orm_exc�UnmappedClassError)�s�instance�owner�mapper�	query_clsrs    ��r�__get__z4scoped_session.query_property.<locals>.query.__get__�s����
 �)�%�0�0�F��A�$�A�#,�9�V�T�]�]�_�_�#M�#M�#M�M�$(�=�=�?�?�#8�#8��#@�#@�@�
A�A���1� � � ��4�4� ���s�1A�&A�A1�0A1N)�__name__�
__module__�__qualname__r1)r0rs��rr)r&�s3�������
 �
 �
 �
 �
 �
 �
 �
 rr))�object)rr0r)s`` r�query_propertyzscoped_session.query_propertyrsJ����4	 �	 �	 �	 �	 �	 �	 �	 �F�	 �	 �	 ��u�w�w�r�N)
r2r3r4�__doc__r
rrr r"r6rrrr
r
s����������O��
A�A�A�A�.#�#�#�0���"1�1�1�"(�(�(�(�(�(rc����fd�}|S)Nc�T��t|������|i|��Sr7��getattrr)r�argsr#�names   �r�dozinstrument.<locals>.do�s*���-�w�t�}�}����-�-�t�>�v�>�>�>rr�r>r?s` r�
instrumentrA�s#���?�?�?�?�?��Irc�8���fd�}�fd�}t||��S)Nc�N��t|����|��dSr7)�setattrr)r�attrr>s  �r�set_zmakeprop.<locals>.set_�s#�����
�
����t�,�,�,�,�,rc�H��t|������Sr7r;)rr>s �r�getzmakeprop.<locals>.get�s����t�}�}����-�-�-r)�property)r>rFrHs`  r�makeproprJ�sG���-�-�-�-�-�.�.�.�.�.��C����r)
�bind�dirty�deleted�new�identity_map�	is_active�	autoflush�no_autoflush�info�
autocommitc�,���fd�}t|��S)Nc�:��tt���|i|��Sr7)r<r)�clsr=r#r>s   �rr?zclslevel.<locals>.do�s"���%�w�w��%�%�t�6�v�6�6�6r)�classmethodr@s` r�clslevelrY�s*���7�7�7�7�7��r�?�?�r)�	close_all�object_session�identity_keyN)�rrr*r(rr�utilrrr	�__all__r5r
�
ScopedSessionrA�public_methods�methrDrJ�proprYrrr�<module>rds���������������������������!�!�!�!�!�!�&�&�&�&�&�&��������
��F�F�F�F�F�V�F�F�F�R�
�+����
�"�4�4�D��G�N�D�*�*�T�"2�"2�3�3�3�3����
�2�2�D��G�N�D�(�(�4�.�.�1�1�1�1����
<�2�2�D��G�N�D�(�(�4�.�.�1�1�1�1�2�2r

Hacked By AnonymousFox1.0, Coded By AnonymousFox