Hackfut Security File Manager
Current Path:
/opt/alt/python27/lib64/python2.7/site-packages/sqlalchemy/orm
opt
/
alt
/
python27
/
lib64
/
python2.7
/
site-packages
/
sqlalchemy
/
orm
/
📁
..
📄
__init__.py
(7.9 KB)
📄
__init__.pyc
(9.31 KB)
📄
__init__.pyo
(9.31 KB)
📄
attributes.py
(55.94 KB)
📄
attributes.pyc
(55.59 KB)
📄
attributes.pyo
(55.32 KB)
📄
base.py
(14.32 KB)
📄
base.pyc
(15.11 KB)
📄
base.pyo
(15.11 KB)
📄
collections.py
(51.18 KB)
📄
collections.pyc
(62.31 KB)
📄
collections.pyo
(62.1 KB)
📄
dependency.py
(45.11 KB)
📄
dependency.pyc
(28.68 KB)
📄
dependency.pyo
(28.59 KB)
📄
deprecated_interfaces.py
(17.83 KB)
📄
deprecated_interfaces.pyc
(21.11 KB)
📄
deprecated_interfaces.pyo
(21.11 KB)
📄
descriptor_props.py
(24.95 KB)
📄
descriptor_props.pyc
(28.1 KB)
📄
descriptor_props.pyo
(28.1 KB)
📄
dynamic.py
(12.84 KB)
📄
dynamic.pyc
(14.42 KB)
📄
dynamic.pyo
(14.42 KB)
📄
evaluator.py
(4.7 KB)
📄
evaluator.pyc
(7.19 KB)
📄
evaluator.pyo
(7.19 KB)
📄
events.py
(83.09 KB)
📄
events.pyc
(91.58 KB)
📄
events.pyo
(91.58 KB)
📄
exc.py
(5.31 KB)
📄
exc.pyc
(7.75 KB)
📄
exc.pyo
(7.75 KB)
📄
identity.py
(10.01 KB)
📄
identity.pyc
(14.76 KB)
📄
identity.pyo
(14.76 KB)
📄
instrumentation.py
(17.1 KB)
📄
instrumentation.pyc
(20.65 KB)
📄
instrumentation.pyo
(20.57 KB)
📄
interfaces.py
(21.56 KB)
📄
interfaces.pyc
(26.11 KB)
📄
interfaces.pyo
(26.11 KB)
📄
loading.py
(25.29 KB)
📄
loading.pyc
(15.28 KB)
📄
loading.pyo
(15.28 KB)
📄
mapper.py
(116.54 KB)
📄
mapper.pyc
(92.81 KB)
📄
mapper.pyo
(92.66 KB)
📄
path_registry.py
(7.57 KB)
📄
path_registry.pyc
(12.58 KB)
📄
path_registry.pyo
(12.58 KB)
📄
persistence.py
(52.41 KB)
📄
persistence.pyc
(41.25 KB)
📄
persistence.pyo
(41.25 KB)
📄
properties.py
(10.21 KB)
📄
properties.pyc
(11.3 KB)
📄
properties.pyo
(11.3 KB)
📄
query.py
(150.98 KB)
📄
query.pyc
(143.06 KB)
📄
query.pyo
(143.02 KB)
📄
relationships.py
(115.47 KB)
📄
relationships.pyc
(100.36 KB)
📄
relationships.pyo
(100.33 KB)
📄
scoping.py
(6.27 KB)
📄
scoping.pyc
(7.5 KB)
📄
scoping.pyo
(7.5 KB)
📄
session.py
(117.07 KB)
📄
session.pyc
(110.77 KB)
📄
session.pyo
(110.6 KB)
📄
state.py
(26.85 KB)
📄
state.pyc
(28.61 KB)
📄
state.pyo
(28.61 KB)
📄
strategies.py
(60.93 KB)
📄
strategies.pyc
(45.88 KB)
📄
strategies.pyo
(45.54 KB)
📄
strategy_options.py
(35.07 KB)
📄
strategy_options.pyc
(36.87 KB)
📄
strategy_options.pyo
(36.87 KB)
📄
sync.py
(5.32 KB)
📄
sync.pyc
(4.48 KB)
📄
sync.pyo
(4.48 KB)
📄
unitofwork.py
(23.43 KB)
📄
unitofwork.pyc
(23.57 KB)
📄
unitofwork.pyo
(23.49 KB)
📄
util.py
(37.64 KB)
📄
util.pyc
(38.09 KB)
📄
util.pyo
(37.94 KB)
Editing: identity.py
# orm/identity.py # Copyright (C) 2005-2017 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 import weakref from . import attributes from .. import util from .. import exc as sa_exc from . import util as orm_util class IdentityMap(object): def __init__(self): self._dict = {} self._modified = set() self._wr = weakref.ref(self) def keys(self): return self._dict.keys() def replace(self, state): raise NotImplementedError() def add(self, state): raise NotImplementedError() def _add_unpresent(self, state, key): """optional inlined form of add() which can assume item isn't present in the map""" self.add(state) def update(self, dict): raise NotImplementedError("IdentityMap uses add() to insert data") def clear(self): raise NotImplementedError("IdentityMap uses remove() to remove data") def _manage_incoming_state(self, state): state._instance_dict = self._wr if state.modified: self._modified.add(state) def _manage_removed_state(self, state): del state._instance_dict if state.modified: self._modified.discard(state) def _dirty_states(self): return self._modified def check_modified(self): """return True if any InstanceStates present have been marked as 'modified'. """ return bool(self._modified) def has_key(self, key): return key in self def popitem(self): raise NotImplementedError("IdentityMap uses remove() to remove data") def pop(self, key, *args): raise NotImplementedError("IdentityMap uses remove() to remove data") def setdefault(self, key, default=None): raise NotImplementedError("IdentityMap uses add() to insert data") def __len__(self): return len(self._dict) def copy(self): raise NotImplementedError() def __setitem__(self, key, value): raise NotImplementedError("IdentityMap uses add() to insert data") def __delitem__(self, key): raise NotImplementedError("IdentityMap uses remove() to remove data") class WeakInstanceDict(IdentityMap): def __getitem__(self, key): state = self._dict[key] o = state.obj() if o is None: raise KeyError(key) return o def __contains__(self, key): try: if key in self._dict: state = self._dict[key] o = state.obj() else: return False except KeyError: return False else: return o is not None def contains_state(self, state): if state.key in self._dict: try: return self._dict[state.key] is state except KeyError: return False else: return False def replace(self, state): if state.key in self._dict: try: existing = self._dict[state.key] except KeyError: # catch gc removed the key after we just checked for it pass else: if existing is not state: self._manage_removed_state(existing) else: return self._dict[state.key] = state self._manage_incoming_state(state) def add(self, state): key = state.key # inline of self.__contains__ if key in self._dict: try: existing_state = self._dict[key] except KeyError: # catch gc removed the key after we just checked for it pass else: if existing_state is not state: o = existing_state.obj() if o is not None: raise sa_exc.InvalidRequestError( "Can't attach instance " "%s; another instance with key %s is already " "present in this session." % ( orm_util.state_str(state), state.key)) else: return False self._dict[key] = state self._manage_incoming_state(state) return True def _add_unpresent(self, state, key): # inlined form of add() called by loading.py self._dict[key] = state state._instance_dict = self._wr def get(self, key, default=None): if key not in self._dict: return default try: state = self._dict[key] except KeyError: # catch gc removed the key after we just checked for it return default else: o = state.obj() if o is None: return default return o def items(self): values = self.all_states() result = [] for state in values: value = state.obj() if value is not None: result.append((state.key, value)) return result def values(self): values = self.all_states() result = [] for state in values: value = state.obj() if value is not None: result.append(value) return result def __iter__(self): return iter(self.keys()) if util.py2k: def iteritems(self): return iter(self.items()) def itervalues(self): return iter(self.values()) def all_states(self): if util.py2k: return self._dict.values() else: return list(self._dict.values()) def _fast_discard(self, state): # used by InstanceState for state being # GC'ed, inlines _managed_removed_state try: st = self._dict[state.key] except KeyError: # catch gc removed the key after we just checked for it pass else: if st is state: self._dict.pop(state.key, None) def discard(self, state): self.safe_discard(state) def safe_discard(self, state): if state.key in self._dict: try: st = self._dict[state.key] except KeyError: # catch gc removed the key after we just checked for it pass else: if st is state: self._dict.pop(state.key, None) self._manage_removed_state(state) def prune(self): return 0 class StrongInstanceDict(IdentityMap): """A 'strong-referencing' version of the identity map. .. deprecated 1.1:: The strong reference identity map is legacy. See the recipe at :ref:`session_referencing_behavior` for an event-based approach to maintaining strong identity references. """ if util.py2k: def itervalues(self): return self._dict.itervalues() def iteritems(self): return self._dict.iteritems() def __iter__(self): return iter(self.dict_) def __getitem__(self, key): return self._dict[key] def __contains__(self, key): return key in self._dict def get(self, key, default=None): return self._dict.get(key, default) def values(self): return self._dict.values() def items(self): return self._dict.items() def all_states(self): return [attributes.instance_state(o) for o in self.values()] def contains_state(self, state): return ( state.key in self and attributes.instance_state(self[state.key]) is state) def replace(self, state): if state.key in self._dict: existing = self._dict[state.key] existing = attributes.instance_state(existing) if existing is not state: self._manage_removed_state(existing) else: return self._dict[state.key] = state.obj() self._manage_incoming_state(state) def add(self, state): if state.key in self: if attributes.instance_state(self._dict[state.key]) is not state: raise sa_exc.InvalidRequestError( "Can't attach instance " "%s; another instance with key %s is already " "present in this session." % ( orm_util.state_str(state), state.key)) return False else: self._dict[state.key] = state.obj() self._manage_incoming_state(state) return True def _add_unpresent(self, state, key): # inlined form of add() called by loading.py self._dict[key] = state.obj() state._instance_dict = self._wr def _fast_discard(self, state): # used by InstanceState for state being # GC'ed, inlines _managed_removed_state try: obj = self._dict[state.key] except KeyError: # catch gc removed the key after we just checked for it pass else: if attributes.instance_state(obj) is state: self._dict.pop(state.key, None) def discard(self, state): self.safe_discard(state) def safe_discard(self, state): if state.key in self._dict: obj = self._dict[state.key] st = attributes.instance_state(obj) if st is state: self._dict.pop(state.key, None) self._manage_removed_state(state) def prune(self): """prune unreferenced, non-dirty states.""" ref_count = len(self) dirty = [s.obj() for s in self.all_states() if s.modified] # work around http://bugs.python.org/issue6149 keepers = weakref.WeakValueDictionary() keepers.update(self) self._dict.clear() self._dict.update(keepers) self.modified = bool(dirty) return ref_count - len(self)
Upload File
Create Folder