def index_doc(doc): catalog = find_catalog(doc) if hasattr(doc, "docid"): # Already in catalog, reindex catalog.reindex_doc(doc) else: # New document catalog.index_doc(doc)
def test_find_catalog(self): from jove_catalog.utils import find_catalog home = { 'content': testing.DummyResource(), 'jove_catalog': {None: 'thecatalog'}, } root = home['content'] root.__home__ = home self.assertEqual(find_catalog(root), 'thecatalog')
def search(context, request): term = request.params.get('term') if term: catalog = find_catalog(context) count, docids, resolve = catalog.query( 'term in text', sort_index='text', names={'term': request.params.get('term')}) results = [resolve(docid) for docid in docids] else: results = [] return {'title': 'Search Results', 'results': results}
def unindex_doc(doc): catalog = find_catalog(doc) catalog.unindex_doc(doc)