Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
clear() method for IMongoContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
kedder committed Aug 12, 2014
1 parent 835ed59 commit 3442de7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/mongopersist/zope/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ def find_one(self, spec_or_id=None, *args, **kwargs):
return None
return self._load_one(doc)

def clear(self):
for key in self.keys():
del self[key]


class IdNamesMongoContainer(MongoContainer):
"""A container that uses the Mongo ObjectId as the name/key."""
Expand Down
7 changes: 7 additions & 0 deletions src/mongopersist/zope/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,10 @@ def add(value, key=None):
- in case _m_mapping_key is None: the object's OID
- otherwise getattr(value, _m_mapping_key)
"""

def clear(self):
"""Delete all items from this container.
Note, that this will not touch all items from the collection, but only
those, specified in _m_get_items_filter.
"""

0 comments on commit 3442de7

Please sign in to comment.