def load(self, name):
     '''Load a single document with given `name`.'''
     assert isinstance(name, unicode)
     results = list(self._documents.find({'name': name}))
     if len(results) == 0:
         raise self._not_exists(name)
     return Document.from_dict(results[0])
Ejemplo n.º 2
0
 def test_from_dict(self):
     A = Document(self.name(), self.text(), self.metadata())
     B = Document.from_dict(self.dictionary())
     self.assertEqual(A, B)
 def _iterator(self, cursor):
     for entry in cursor:
         yield Document.from_dict(entry)