Commits

Joshua Elsasser committed ad61b4d

Add a new document_data flag to query() which returns just the document and its data.

Unlike the existing document flag plus a get_data() call, the new
document_data flag gets you all the fancy DatabaseError retry logic.

  • Participants
  • Parent commits eeee766
  • Tags release-0.4.23

Comments (0)

Files changed (1)

File xodb/database.py

               match_decider=None,
               match_spy=None,
               document=False,
+              document_data=False,
               echo=False,
               parser_flags=default_parser_flags,
               default_op=Query.OP_AND,
                             logger.warning(
                                 "Document %d is gone, skipping.", docid)
                             continue
-                        typ, data = loads(data)
                         seen.add(docid)
-                        yield self.record_factory(_lookup_schema(typ).from_flat(data),
-                                                  doc,
-                                                  record.percent,
-                                                  record.rank,
-                                                  record.weight,
-                                                  )
+                        if document_data:
+                            yield doc, data
+                        else:
+                            typ, data = loads(data)
+                            yield self.record_factory(_lookup_schema(typ).from_flat(data),
+                                                      doc,
+                                                      record.percent,
+                                                      record.rank,
+                                                      record.weight,
+                                                      )
                 # no errors exhuasting the set? break out and we're done
                 break
             except xapian.DatabaseError, e: