Exemplo n.º 1
0
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)
Exemplo n.º 2
0
 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')
Exemplo n.º 3
0
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}
Exemplo n.º 4
0
def unindex_doc(doc):
    catalog = find_catalog(doc)
    catalog.unindex_doc(doc)