/
opt
/
alt
/
python27
/
lib64
/
python2.7
/
site-packages
/
sqlalchemy
/
orm
/
/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm
mkdir
upload
Name
Size
Mode
Actions
attributes.py
67137
0644
edit
dl
rm
attributes.pyc
62129
0644
edit
dl
rm
attributes.pyo
61851
0644
edit
dl
rm
base.py
14864
0644
edit
dl
rm
base.pyc
15558
0644
edit
dl
rm
base.pyo
15558
0644
edit
dl
rm
collections.py
52614
0644
edit
dl
rm
collections.pyc
63448
0644
edit
dl
rm
collections.pyo
63226
0644
edit
dl
rm
dependency.py
46556
0644
edit
dl
rm
dependency.pyc
29624
0644
edit
dl
rm
dependency.pyo
29533
0644
edit
dl
rm
deprecated_interfaces.py
20751
0644
edit
dl
rm
deprecated_interfaces.pyc
22776
0644
edit
dl
rm
deprecated_interfaces.pyo
22776
0644
edit
dl
rm
descriptor_props.py
28201
0644
edit
dl
rm
descriptor_props.pyc
32216
0644
edit
dl
rm
descriptor_props.pyo
32216
0644
edit
dl
rm
dynamic.py
14666
0644
edit
dl
rm
dynamic.pyc
15339
0644
edit
dl
rm
dynamic.pyo
15339
0644
edit
dl
rm
evaluator.py
5441
0644
edit
dl
rm
evaluator.pyc
7819
0644
edit
dl
rm
evaluator.pyo
7819
0644
edit
dl
rm
events.py
94409
0644
edit
dl
rm
events.pyc
103665
0644
edit
dl
rm
events.pyo
103665
0644
edit
dl
rm
exc.py
6610
0644
edit
dl
rm
exc.pyc
8838
0644
edit
dl
rm
exc.pyo
8838
0644
edit
dl
rm
identity.py
10299
0644
edit
dl
rm
identity.pyc
15109
0644
edit
dl
rm
identity.pyo
15109
0644
edit
dl
rm
instrumentation.py
18131
0644
edit
dl
rm
instrumentation.pyc
21633
0644
edit
dl
rm
instrumentation.pyo
21544
0644
edit
dl
rm
interfaces.py
25766
0644
edit
dl
rm
interfaces.pyc
30234
0644
edit
dl
rm
interfaces.pyo
30234
0644
edit
dl
rm
loading.py
32236
0644
edit
dl
rm
loading.pyc
20574
0644
edit
dl
rm
loading.pyo
20549
0644
edit
dl
rm
mapper.py
128344
0644
edit
dl
rm
mapper.pyc
100412
0644
edit
dl
rm
mapper.pyo
100198
0644
edit
dl
rm
path_registry.py
9262
0644
edit
dl
rm
path_registry.pyc
13256
0644
edit
dl
rm
path_registry.pyo
13256
0644
edit
dl
rm
persistence.py
65652
0644
edit
dl
rm
persistence.pyc
46786
0644
edit
dl
rm
persistence.pyo
46786
0644
edit
dl
rm
properties.py
11043
0644
edit
dl
rm
properties.pyc
12111
0644
edit
dl
rm
properties.pyo
12111
0644
edit
dl
rm
query.py
172590
0644
edit
dl
rm
query.pyc
155014
0644
edit
dl
rm
query.pyo
154936
0644
edit
dl
rm
relationships.py
124442
0644
edit
dl
rm
relationships.pyc
105318
0644
edit
dl
rm
relationships.pyo
105293
0644
edit
dl
rm
scoping.py
6393
0644
edit
dl
rm
scoping.pyc
7680
0644
edit
dl
rm
scoping.pyo
7680
0644
edit
dl
rm
session.py
128754
0644
edit
dl
rm
session.pyc
120117
0644
edit
dl
rm
session.pyo
119938
0644
edit
dl
rm
state.py
31044
0644
edit
dl
rm
state.pyc
32294
0644
edit
dl
rm
state.pyo
32238
0644
edit
dl
rm
strategies.py
84602
0644
edit
dl
rm
strategies.pyc
63019
0644
edit
dl
rm
strategies.pyo
62668
0644
edit
dl
rm
strategy_options.py
55505
0644
edit
dl
rm
strategy_options.pyc
52730
0644
edit
dl
rm
strategy_options.pyo
52596
0644
edit
dl
rm
sync.py
5536
0644
edit
dl
rm
sync.pyc
4628
0644
edit
dl
rm
sync.pyo
4628
0644
edit
dl
rm
unitofwork.py
24735
0644
edit
dl
rm
unitofwork.pyc
24565
0644
edit
dl
rm
unitofwork.pyo
24489
0644
edit
dl
rm
util.py
44859
0644
edit
dl
rm
util.pyc
44363
0644
edit
dl
rm
util.pyo
44211
0644
edit
dl
rm
__init__.py
9542
0644
edit
dl
rm
__init__.pyc
10759
0644
edit
dl
rm
__init__.pyo
10759
0644
edit
dl
rm
Edit:
/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm/path_registry.py
(9262B)
# orm/path_registry.py # Copyright (C) 2005-2019 the SQLAlchemy authors and contributors # <see AUTHORS file> # # This module is part of SQLAlchemy and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php """Path tracking utilities, representing mapper graph traversals. """ from itertools import chain import logging from .base import class_mapper from .. import exc from .. import inspection from .. import util log = logging.getLogger(__name__) def _unreduce_path(path): return PathRegistry.deserialize(path) _WILDCARD_TOKEN = "*" _DEFAULT_TOKEN = "_sa_default" class PathRegistry(object): """Represent query load paths and registry functions. Basically represents structures like: (<User mapper>, "orders", <Order mapper>, "items", <Item mapper>) These structures are generated by things like query options (joinedload(), subqueryload(), etc.) and are used to compose keys stored in the query._attributes dictionary for various options. They are then re-composed at query compile/result row time as the query is formed and as rows are fetched, where they again serve to compose keys to look up options in the context.attributes dictionary, which is copied from query._attributes. The path structure has a limited amount of caching, where each "root" ultimately pulls from a fixed registry associated with the first mapper, that also contains elements for each of its property keys. However paths longer than two elements, which are the exception rather than the rule, are generated on an as-needed basis. """ is_token = False is_root = False def __eq__(self, other): return other is not None and self.path == other.path def set(self, attributes, key, value): log.debug("set '%s' on path '%s' to '%s'", key, self, value) attributes[(key, self.natural_path)] = value def setdefault(self, attributes, key, value): log.debug("setdefault '%s' on path '%s' to '%s'", key, self, value) attributes.setdefault((key, self.natural_path), value) def get(self, attributes, key, value=None): key = (key, self.natural_path) if key in attributes: return attributes[key] else: return value def __len__(self): return len(self.path) @property def length(self): return len(self.path) def pairs(self): path = self.path for i in range(0, len(path), 2): yield path[i], path[i + 1] def contains_mapper(self, mapper): for path_mapper in [self.path[i] for i in range(0, len(self.path), 2)]: if path_mapper.is_mapper and path_mapper.isa(mapper): return True else: return False def contains(self, attributes, key): return (key, self.path) in attributes def __reduce__(self): return _unreduce_path, (self.serialize(),) def serialize(self): path = self.path return list( zip( [m.class_ for m in [path[i] for i in range(0, len(path), 2)]], [path[i].key for i in range(1, len(path), 2)] + [None], ) ) @classmethod def deserialize(cls, path): if path is None: return None p = tuple( chain( *[ ( class_mapper(mcls), class_mapper(mcls).attrs[key] if key is not None else None, ) for mcls, key in path ] ) ) if p and p[-1] is None: p = p[0:-1] return cls.coerce(p) @classmethod def per_mapper(cls, mapper): return EntityRegistry(cls.root, mapper) @classmethod def coerce(cls, raw): return util.reduce(lambda prev, next: prev[next], raw, cls.root) def token(self, token): if token.endswith(":" + _WILDCARD_TOKEN): return TokenRegistry(self, token) elif token.endswith(":" + _DEFAULT_TOKEN): return TokenRegistry(self.root, token) else: raise exc.ArgumentError("invalid token: %s" % token) def __add__(self, other): return util.reduce(lambda prev, next: prev[next], other.path, self) def __repr__(self): return "%s(%r)" % (self.__class__.__name__, self.path) class RootRegistry(PathRegistry): """Root registry, defers to mappers so that paths are maintained per-root-mapper. """ path = natural_path = () has_entity = False is_aliased_class = False is_root = True def __getitem__(self, entity): return entity._path_registry PathRegistry.root = RootRegistry() class TokenRegistry(PathRegistry): def __init__(self, parent, token): self.token = token self.parent = parent self.path = parent.path + (token,) self.natural_path = parent.natural_path + (token,) has_entity = False is_token = True def generate_for_superclasses(self): if not self.parent.is_aliased_class and not self.parent.is_root: for ent in self.parent.mapper.iterate_to_root(): yield TokenRegistry(self.parent.parent[ent], self.token) elif ( self.parent.is_aliased_class and self.parent.entity._is_with_polymorphic ): yield self for ent in self.parent.entity._with_polymorphic_entities: yield TokenRegistry(self.parent.parent[ent], self.token) else: yield self def __getitem__(self, entity): raise NotImplementedError() class PropRegistry(PathRegistry): def __init__(self, parent, prop): # restate this path in terms of the # given MapperProperty's parent. insp = inspection.inspect(parent[-1]) if not insp.is_aliased_class or insp._use_mapper_path: parent = parent.parent[prop.parent] elif insp.is_aliased_class and insp.with_polymorphic_mappers: if ( prop.parent is not insp.mapper and prop.parent in insp.with_polymorphic_mappers ): subclass_entity = parent[-1]._entity_for_mapper(prop.parent) parent = parent.parent[subclass_entity] self.prop = prop self.parent = parent self.path = parent.path + (prop,) self.natural_path = parent.natural_path + (prop,) self._wildcard_path_loader_key = ( "loader", self.parent.path + self.prop._wildcard_token, ) self._default_path_loader_key = self.prop._default_path_loader_key self._loader_key = ("loader", self.path) def __str__(self): return " -> ".join(str(elem) for elem in self.path) @util.memoized_property def has_entity(self): return hasattr(self.prop, "mapper") @util.memoized_property def entity(self): return self.prop.mapper @property def mapper(self): return self.entity @property def entity_path(self): return self[self.entity] def __getitem__(self, entity): if isinstance(entity, (int, slice)): return self.path[entity] else: return EntityRegistry(self, entity) class EntityRegistry(PathRegistry, dict): is_aliased_class = False has_entity = True def __init__(self, parent, entity): self.key = entity self.parent = parent self.is_aliased_class = entity.is_aliased_class self.entity = entity self.path = parent.path + (entity,) # the "natural path" is the path that we get when Query is traversing # from the lead entities into the various relationships; it corresponds # to the structure of mappers and relationships. when we are given a # path that comes from loader options, as of 1.3 it can have ac-hoc # with_polymorphic() and other AliasedInsp objects inside of it, which # are usually not present in mappings. So here we track both the # "enhanced" path in self.path and the "natural" path that doesn't # include those objects so these two traversals can be matched up. if parent.path and self.is_aliased_class: if entity.mapper.isa(parent.natural_path[-1].entity): self.natural_path = parent.natural_path + (entity.mapper,) else: self.natural_path = parent.natural_path + ( parent.natural_path[-1].entity, ) else: self.natural_path = self.path self.entity_path = self @property def mapper(self): return inspection.inspect(self.entity).mapper def __bool__(self): return True __nonzero__ = __bool__ def __getitem__(self, entity): if isinstance(entity, (int, slice)): return self.path[entity] else: return dict.__getitem__(self, entity) def __missing__(self, key): self[key] = item = PropRegistry(self, key) return item
Save
cmd:
run