diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-12-17 14:19:22 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-12-17 14:19:22 -0500 |
commit | 2e7a54d6fbfe9260887a0eb848e296e3b5e59c47 (patch) | |
tree | 66b121a8a3a984e676acf47997ac119878d7ccd1 /lib/sqlalchemy/orm/collections.py | |
parent | b5f3648188ee46e7c0353d3123f8ed6d55f31b56 (diff) | |
parent | ba964522e15da9062f5ed11e8bf55a0b5fb54693 (diff) | |
download | sqlalchemy-2e7a54d6fbfe9260887a0eb848e296e3b5e59c47.tar.gz |
merge tip
Diffstat (limited to 'lib/sqlalchemy/orm/collections.py')
-rw-r--r-- | lib/sqlalchemy/orm/collections.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/collections.py b/lib/sqlalchemy/orm/collections.py index b52329523..99e6464f2 100644 --- a/lib/sqlalchemy/orm/collections.py +++ b/lib/sqlalchemy/orm/collections.py @@ -471,6 +471,9 @@ class CollectionAdapter(object): The ORM uses an CollectionAdapter exclusively for interaction with entity collections. + 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 @@ -553,6 +556,12 @@ class CollectionAdapter(object): """Add or restore an entity to the collection, firing no events.""" getattr(self._data(), '_sa_appender')(item, _sa_initiator=False) + def append_multiple_without_event(self, items): + """Add or restore an entity to the collection, firing no events.""" + appender = getattr(self._data(), '_sa_appender') + for item in items: + appender(item, _sa_initiator=False) + def remove_with_event(self, item, initiator=None): """Remove an entity from the collection, firing mutation events.""" getattr(self._data(), '_sa_remover')(item, _sa_initiator=initiator) @@ -563,13 +572,17 @@ 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): - self.remove_with_event(item, initiator) + remover(item, _sa_initiator=initiator) def clear_without_event(self): """Empty the collection, firing no events.""" + + remover = getattr(self._data(), '_sa_remover') for item in list(self): - self.remove_without_event(item) + remover(item, _sa_initiator=False) def __iter__(self): """Iterate over entities in the collection.""" |