diff options
Diffstat (limited to 'lib/sqlalchemy/orm/collections.py')
| -rw-r--r-- | lib/sqlalchemy/orm/collections.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/sqlalchemy/orm/collections.py b/lib/sqlalchemy/orm/collections.py index b0fab36c0..4b03a50db 100644 --- a/lib/sqlalchemy/orm/collections.py +++ b/lib/sqlalchemy/orm/collections.py @@ -449,7 +449,7 @@ class collection(object): # implementations def collection_adapter(collection): """Fetch the :class:`.CollectionAdapter` for a collection.""" - + return getattr(collection, '_sa_adapter', None) def collection_iter(collection): @@ -479,14 +479,14 @@ class CollectionAdapter(object): The usage of getattr()/setattr() is currently to allow injection of custom methods, such as to unwrap Zope security proxies. - + """ def __init__(self, attr, owner_state, data): self._key = attr.key self._data = weakref.ref(data) self.owner_state = owner_state self.link_to_self(data) - + @property def data(self): "The entity collection being adapted." @@ -495,7 +495,7 @@ class CollectionAdapter(object): @util.memoized_property def attr(self): return self.owner_state.manager[self._key].impl - + def link_to_self(self, data): """Link a collection to this adapter, and fire a link event.""" setattr(data, '_sa_adapter', self) @@ -555,7 +555,7 @@ class CollectionAdapter(object): def append_with_event(self, item, initiator=None): """Add an entity to the collection, firing mutation events.""" - + getattr(self._data(), '_sa_appender')(item, _sa_initiator=initiator) def append_without_event(self, item): @@ -578,7 +578,7 @@ class CollectionAdapter(object): def clear_with_event(self, initiator=None): """Empty the collection, firing a mutation event for each entity.""" - + remover = getattr(self._data(), '_sa_remover') for item in list(self): remover(item, _sa_initiator=initiator) @@ -592,7 +592,7 @@ class CollectionAdapter(object): def __iter__(self): """Iterate over entities in the collection.""" - + # Py3K requires iter() here return iter(getattr(self._data(), '_sa_iterator')()) @@ -926,7 +926,7 @@ def __set(collection, item, _sa_initiator=None): if executor: item = getattr(executor, 'fire_append_event')(item, _sa_initiator) return item - + def __del(collection, item, _sa_initiator=None): """Run del events, may eventually be inlined into decorators.""" if _sa_initiator is not False and item is not None: @@ -987,12 +987,12 @@ def _list_decorators(): stop = index.stop or len(self) if stop < 0: stop += len(self) - + if step == 1: for i in xrange(start, stop, step): if len(self) > start: del self[start] - + for i, item in enumerate(value): self.insert(i + start, item) else: @@ -1041,7 +1041,7 @@ def _list_decorators(): _tidy(__delslice__) return __delslice__ # end Py2K - + def extend(fn): def extend(self, iterable): for value in iterable: @@ -1371,7 +1371,7 @@ class InstrumentedDict(dict): __instrumentation__ = { 'iterator': 'itervalues', } # end Py2K - + __canned_instrumentation = { list: InstrumentedList, set: InstrumentedSet, |
