$85 GRAYBYTE WORDPRESS FILE MANAGER $34

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/lib64/python2.7/site-packages/sqlalchemy/orm/

HOME
Current File : /lib64/python2.7/site-packages/sqlalchemy/orm//sync.py
# orm/sync.py
# Copyright (C) 2005-2024 the SQLAlchemy authors and contributors
# <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
# the MIT License: https://www.opensource.org/licenses/mit-license.php

"""private module containing functions used for copying data
between instances based on join conditions.

"""

from . import attributes
from . import exc
from . import util as orm_util
from .. import util


def populate(
    source,
    source_mapper,
    dest,
    dest_mapper,
    synchronize_pairs,
    uowcommit,
    flag_cascaded_pks,
):
    source_dict = source.dict
    dest_dict = dest.dict

    for l, r in synchronize_pairs:
        try:
            # inline of source_mapper._get_state_attr_by_column
            prop = source_mapper._columntoproperty[l]
            value = source.manager[prop.key].impl.get(
                source, source_dict, attributes.PASSIVE_OFF
            )
        except exc.UnmappedColumnError as err:
            _raise_col_to_prop(False, source_mapper, l, dest_mapper, r, err)

        try:
            # inline of dest_mapper._set_state_attr_by_column
            prop = dest_mapper._columntoproperty[r]
            dest.manager[prop.key].impl.set(dest, dest_dict, value, None)
        except exc.UnmappedColumnError as err:
            _raise_col_to_prop(True, source_mapper, l, dest_mapper, r, err)

        # technically the "r.primary_key" check isn't
        # needed here, but we check for this condition to limit
        # how often this logic is invoked for memory/performance
        # reasons, since we only need this info for a primary key
        # destination.
        if (
            flag_cascaded_pks
            and l.primary_key
            and r.primary_key
            and r.references(l)
        ):
            uowcommit.attributes[("pk_cascaded", dest, r)] = True


def bulk_populate_inherit_keys(source_dict, source_mapper, synchronize_pairs):
    # a simplified version of populate() used by bulk insert mode
    for l, r in synchronize_pairs:
        try:
            prop = source_mapper._columntoproperty[l]
            value = source_dict[prop.key]
        except exc.UnmappedColumnError as err:
            _raise_col_to_prop(False, source_mapper, l, source_mapper, r, err)

        try:
            prop = source_mapper._columntoproperty[r]
            source_dict[prop.key] = value
        except exc.UnmappedColumnError:
            _raise_col_to_prop(True, source_mapper, l, source_mapper, r)


def clear(dest, dest_mapper, synchronize_pairs):
    for l, r in synchronize_pairs:
        if (
            r.primary_key
            and dest_mapper._get_state_attr_by_column(dest, dest.dict, r)
            not in orm_util._none_set
        ):

            raise AssertionError(
                "Dependency rule tried to blank-out primary key "
                "column '%s' on instance '%s'" % (r, orm_util.state_str(dest))
            )
        try:
            dest_mapper._set_state_attr_by_column(dest, dest.dict, r, None)
        except exc.UnmappedColumnError as err:
            _raise_col_to_prop(True, None, l, dest_mapper, r, err)


def update(source, source_mapper, dest, old_prefix, synchronize_pairs):
    for l, r in synchronize_pairs:
        try:
            oldvalue = source_mapper._get_committed_attr_by_column(
                source.obj(), l
            )
            value = source_mapper._get_state_attr_by_column(
                source, source.dict, l, passive=attributes.PASSIVE_OFF
            )
        except exc.UnmappedColumnError as err:
            _raise_col_to_prop(False, source_mapper, l, None, r, err)
        dest[r.key] = value
        dest[old_prefix + r.key] = oldvalue


def populate_dict(source, source_mapper, dict_, synchronize_pairs):
    for l, r in synchronize_pairs:
        try:
            value = source_mapper._get_state_attr_by_column(
                source, source.dict, l, passive=attributes.PASSIVE_OFF
            )
        except exc.UnmappedColumnError as err:
            _raise_col_to_prop(False, source_mapper, l, None, r, err)

        dict_[r.key] = value


def source_modified(uowcommit, source, source_mapper, synchronize_pairs):
    """return true if the source object has changes from an old to a
    new value on the given synchronize pairs

    """
    for l, r in synchronize_pairs:
        try:
            prop = source_mapper._columntoproperty[l]
        except exc.UnmappedColumnError as err:
            _raise_col_to_prop(False, source_mapper, l, None, r, err)
        history = uowcommit.get_attribute_history(
            source, prop.key, attributes.PASSIVE_NO_INITIALIZE
        )
        if bool(history.deleted):
            return True
    else:
        return False


def _raise_col_to_prop(
    isdest, source_mapper, source_column, dest_mapper, dest_column, err
):
    if isdest:
        util.raise_(
            exc.UnmappedColumnError(
                "Can't execute sync rule for "
                "destination column '%s'; mapper '%s' does not map "
                "this column.  Try using an explicit `foreign_keys` "
                "collection which does not include this column (or use "
                "a viewonly=True relation)." % (dest_column, dest_mapper)
            ),
            replace_context=err,
        )
    else:
        util.raise_(
            exc.UnmappedColumnError(
                "Can't execute sync rule for "
                "source column '%s'; mapper '%s' does not map this "
                "column.  Try using an explicit `foreign_keys` "
                "collection which does not include destination column "
                "'%s' (or use a viewonly=True relation)."
                % (source_column, source_mapper, dest_column)
            ),
            replace_context=err,
        )

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
23 Sep 2024 10.41 AM
root / root
0755
__init__.py
10.707 KB
5 Sep 2024 10.50 PM
root / root
0644
__init__.pyc
12.471 KB
23 Sep 2024 10.41 AM
root / root
0644
attributes.py
75.885 KB
5 Sep 2024 10.50 PM
root / root
0644
attributes.pyc
68.515 KB
23 Sep 2024 10.41 AM
root / root
0644
base.py
14.881 KB
5 Sep 2024 10.50 PM
root / root
0644
base.pyc
14.961 KB
23 Sep 2024 10.41 AM
root / root
0644
clsregistry.py
12.987 KB
5 Sep 2024 10.50 PM
root / root
0644
clsregistry.pyc
14.702 KB
23 Sep 2024 10.41 AM
root / root
0644
collections.py
53.44 KB
5 Sep 2024 10.50 PM
root / root
0644
collections.pyc
61.913 KB
23 Sep 2024 10.41 AM
root / root
0644
context.py
108.652 KB
5 Sep 2024 10.50 PM
root / root
0644
context.pyc
61.606 KB
23 Sep 2024 10.41 AM
root / root
0644
decl_api.py
34.724 KB
5 Sep 2024 10.50 PM
root / root
0644
decl_api.pyc
37.08 KB
23 Sep 2024 10.41 AM
root / root
0644
decl_base.py
43.69 KB
5 Sep 2024 10.50 PM
root / root
0644
decl_base.pyc
30.072 KB
23 Sep 2024 10.41 AM
root / root
0644
dependency.py
45.886 KB
5 Sep 2024 10.50 PM
root / root
0644
dependency.pyc
28.217 KB
23 Sep 2024 10.41 AM
root / root
0644
descriptor_props.py
25.378 KB
5 Sep 2024 10.50 PM
root / root
0644
descriptor_props.pyc
27.322 KB
23 Sep 2024 10.41 AM
root / root
0644
dynamic.py
15.638 KB
5 Sep 2024 10.50 PM
root / root
0644
dynamic.pyc
16.155 KB
23 Sep 2024 10.41 AM
root / root
0644
evaluator.py
7.756 KB
5 Sep 2024 10.50 PM
root / root
0644
evaluator.pyc
10.283 KB
23 Sep 2024 10.41 AM
root / root
0644
events.py
109.648 KB
5 Sep 2024 10.50 PM
root / root
0644
events.pyc
116.313 KB
23 Sep 2024 10.41 AM
root / root
0644
exc.py
6.379 KB
5 Sep 2024 10.50 PM
root / root
0644
exc.pyc
8.012 KB
23 Sep 2024 10.41 AM
root / root
0644
identity.py
7.063 KB
5 Sep 2024 10.50 PM
root / root
0644
identity.pyc
9.846 KB
23 Sep 2024 10.41 AM
root / root
0644
instrumentation.py
19.914 KB
5 Sep 2024 10.50 PM
root / root
0644
instrumentation.pyc
21.94 KB
23 Sep 2024 10.41 AM
root / root
0644
interfaces.py
31.586 KB
5 Sep 2024 10.50 PM
root / root
0644
interfaces.pyc
36.536 KB
23 Sep 2024 10.41 AM
root / root
0644
loading.py
48.161 KB
5 Sep 2024 10.50 PM
root / root
0644
loading.pyc
28.739 KB
23 Sep 2024 10.41 AM
root / root
0644
mapper.py
140.959 KB
5 Sep 2024 10.50 PM
root / root
0644
mapper.pyc
106.941 KB
23 Sep 2024 10.41 AM
root / root
0644
path_registry.py
16.008 KB
5 Sep 2024 10.50 PM
root / root
0644
path_registry.pyc
17.739 KB
23 Sep 2024 10.41 AM
root / root
0644
persistence.py
82.275 KB
5 Sep 2024 10.50 PM
root / root
0644
persistence.pyc
48.377 KB
23 Sep 2024 10.41 AM
root / root
0644
properties.py
14.438 KB
5 Sep 2024 10.50 PM
root / root
0644
properties.pyc
14.746 KB
23 Sep 2024 10.41 AM
root / root
0644
query.py
122.999 KB
5 Sep 2024 10.50 PM
root / root
0644
query.pyc
119.512 KB
23 Sep 2024 10.41 AM
root / root
0644
relationships.py
140.622 KB
5 Sep 2024 10.50 PM
root / root
0644
relationships.pyc
114.873 KB
23 Sep 2024 10.41 AM
root / root
0644
scoping.py
7.087 KB
5 Sep 2024 10.50 PM
root / root
0644
scoping.pyc
7.317 KB
23 Sep 2024 10.41 AM
root / root
0644
session.py
158.795 KB
5 Sep 2024 10.50 PM
root / root
0644
session.pyc
142.412 KB
23 Sep 2024 10.41 AM
root / root
0644
state.py
32.738 KB
5 Sep 2024 10.50 PM
root / root
0644
state.pyc
32.091 KB
23 Sep 2024 10.41 AM
root / root
0644
strategies.py
105.8 KB
5 Sep 2024 10.50 PM
root / root
0644
strategies.pyc
65.906 KB
23 Sep 2024 10.41 AM
root / root
0644
strategy_options.py
66.687 KB
5 Sep 2024 10.50 PM
root / root
0644
strategy_options.pyc
58.673 KB
23 Sep 2024 10.41 AM
root / root
0644
sync.py
5.688 KB
5 Sep 2024 10.50 PM
root / root
0644
sync.pyc
4.58 KB
23 Sep 2024 10.41 AM
root / root
0644
unitofwork.py
26.455 KB
5 Sep 2024 10.50 PM
root / root
0644
unitofwork.pyc
24.882 KB
23 Sep 2024 10.41 AM
root / root
0644
util.py
74.473 KB
5 Sep 2024 10.50 PM
root / root
0644
util.pyc
69.456 KB
23 Sep 2024 10.41 AM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF