PK APOCALYPSE V1

APOCALYPSE V1

Current Path : /opt/hc_python/lib/python3.12/site-packages/sqlalchemy/ext/__pycache__/
Upload File :
Current File : //opt/hc_python/lib/python3.12/site-packages/sqlalchemy/ext/__pycache__/serializer.cpython-312.pyc

�

���g��6�dZddlmZddlZddlZddlmZddlmZddlm	Z	ddl
mZdd	lm
Z
dd
lmZddlmZddlmZdd
lmZgd�ZGd�dej,�Zej0d�ZGd�dej4�Zej8fd�Zdd�Zy)akSerializer/Deserializer objects for usage with SQLAlchemy query structures,
allowing "contextual" deserialization.

.. legacy::

    The serializer extension is **legacy** and should not be used for
    new development.

Any SQLAlchemy query structure, either based on sqlalchemy.sql.*
or sqlalchemy.orm.* can be used.  The mappers, Tables, Columns, Session
etc. which are referenced by the structure are not persisted in serialized
form, but are instead re-associated with the query structure
when it is deserialized.

.. warning:: The serializer extension uses pickle to serialize and
   deserialize objects, so the same security consideration mentioned
   in the `python documentation
   <https://docs.python.org/3/library/pickle.html>`_ apply.

Usage is nearly the same as that of the standard Python pickle module::

    from sqlalchemy.ext.serializer import loads, dumps

    metadata = MetaData(bind=some_engine)
    Session = scoped_session(sessionmaker())

    # ... define mappers

    query = (
        Session.query(MyClass)
        .filter(MyClass.somedata == "foo")
        .order_by(MyClass.sortkey)
    )

    # pickle the query
    serialized = dumps(query)

    # unpickle.  Pass in metadata + scoped_session
    query2 = loads(serialized, metadata, Session)

    print(query2.all())

Similar restrictions as when using raw pickle apply; mapped classes must be
themselves be pickleable, meaning they are importable from a module-level
namespace.

The serializer module is only appropriate for query structures.  It is not
needed for:

* instances of user-defined classes.   These contain no references to engines,
  sessions or expression constructs in the typical case and can be serialized
  directly.

* Table metadata that is to be loaded entirely from the serialized structure
  (i.e. is not already declared in the application).   Regular
  pickle.loads()/dumps() can be used to fully dump any ``MetaData`` object,
  typically one which was reflected from an existing database at some previous
  point in time.  The serializer module is specifically for the opposite case,
  where the Table metadata is already present in memory.

�)�BytesION�)�Column)�Table)�Engine)�class_mapper)�MapperProperty)�Mapper)�Session)�	b64decode)�	b64encode)�
Serializer�Deserializer�dumps�loadsc��eZdZd�Zy)rc�6�t|t�r9|js-dtt	j
|j��z}|St|t�r]|jjsGdtt	j
|jj��zdz|jz}|St|t�rYd|jvr:dtt	j
|jdj��z}|Sd|j��}|St|t�rBt|jt�r(d|jj�d|j��}|St|t�rd}|St|t�rd	}|Sy)
Nzmapper:zmapperprop:�:�parententityzmapper_selectable:ztable:zcolumn:zsession:zengine:)�
isinstancer
�non_primaryr
�pickler�class_r	�parent�keyr�_annotationsr�tablerr)�self�obj�id_s   �J/opt/hc_python/lib64/python3.12/site-packages/sqlalchemy/ext/serializer.py�
persistent_idzSerializer.persistent_id[sm���c�6�"�3�?�?��i����S�Z�Z�(@�A�A�C�.�
�-��^�
,�S�Z�Z�5K�5K���F�L�L����):�):�;�<�=����'�'��
�*�
���U�
#���!1�!1�1�*�Y��L�L��!1�!1�.�!A�!H�!H�I�.����
��s�w�w�i�(���
���V�
$��C�I�I�u�)E��C�I�I�M�M�?�!�C�G�G�9�5�C��
�
��W�
%��C�
�
�	��V�
$��C��
��N)�__name__�
__module__�__qualname__r"�r#r!rrYs��r#rzP(mapperprop|mapper|mapper_selectable|table|column|session|attribute|engine):(.*)c�,��eZdZd�fd�	Zd�Zd�Z�xZS)rc�N��t�|�|�||_||_||_y�N)�super�__init__�metadata�scoped_session�engine)r�filer-r.r/�	__class__s     �r!r,zDeserializer.__init__�s&���
����� ��
�,�����r#c��|jr|jS|jr4|j�jr|j�jSyr*)r/r.�bind)rs r!�
get_enginezDeserializer.get_engine�sE���;�;��;�;��
�
 �
 �T�%8�%8�%:�%?�%?��&�&�(�-�-�-�r#c��tjt|��}|sy|jdd�\}}|dk(r>|j	d�\}}tjt|��}t||�S|dk(r)tjt|��}t|�S|dk(r7tjt|��}t|�j�S|dk(rJ|j	d�\}}	tjt|��}t|�j|	S|dk(r|jj|S|d	k(r:|j	d�\}
}|jj|
j|S|d
k(r|j�S|dk(r|j!�St#d|z��)
N�r�	attributer�mapper�mapper_selectable�
mapperpropr�column�sessionr/zUnknown token: %s)�our_ids�match�str�group�splitrrr�getattrr�__clause_element__�attrsr-�tables�cr.r4�	Exception)rr �m�type_�argsr�clsarg�clsr8�keynamer�colnames            r!�persistent_loadzDeserializer.persistent_load�s����M�M�#�c�(�#�����'�'�!�Q�-�K�E�4���#�"�j�j��o���V��l�l�9�V�#4�5���s�C�(�(��(�"��l�l�9�T�?�3��#�C�(�(��-�-��l�l�9�T�?�3��#�C�(�;�;�=�=��,�&�"&�*�*�S�/�����l�l�9�V�#4�5��#�C�(�.�.�w�7�7��'�!��}�}�+�+�D�1�1��(�"�!%���C����w��}�}�+�+�E�2�4�4�W�=�=��)�#��*�*�,�,��(�"����(�(�� 3�e� ;�<�<r#�NNN)r$r%r&r,r4rO�
__classcell__)r1s@r!rr~s�����=r#rc�p�t�}t||�}|j|�|j�Sr*)rr�dump�getvalue)r�protocol�buf�picklers    r!rr�s-��
�)�C���h�'�G��L�L����<�<�>�r#c�T�t|�}t||||�}|j�Sr*)rr�load)�datar-r.r/rV�	unpicklers      r!rr�s(��
�$�-�C��S�(�N�F�C�I��>�>��r#rP)�__doc__�iorr�re�rrr/r�ormr�orm.interfacesr	�
orm.mapperr
�orm.sessionr�utilrr
�__all__�Picklerr�compiler=�	Unpicklerr�HIGHEST_PROTOCOLrrr'r#r!�<module>rjs���<�|�
�	�����+��!���;�������>�"�*�*�&���.=�6�#�#�.=�b�/�/��r#

if you don't want to be vaporized in a nuclear explosion, i simply have to become nuclear myself… i am atomic