def index_pages(): db = xapian.WritableDatabase(xapian.open(config.search_db_dir, xapian.DB_CREATE_OR_OPEN)) try: for page_name in request.rootpage.getPageList(): # missing request page = Page.Page(request, page_name) # XXX missing request update_page(page, db) db.flush() finally: db.__del__()
def openIndex(klass, readOnly, *args, **kwargs): try: if readOnly: assert len(kwargs) == 0 # assume all args are db paths db = xapian.Database(args[0]) for path in args[1:]: db.add_database(xapian.Database(path)) return klass(db) else: try: return klass(xapian.WritableDatabase(*args, **kwargs)) # for xapian 1.0+ except AttributeError: return klass(xapian.open(*args, **kwargs)) # for xapian 0.9.x except (IOError, RuntimeError, ValueError), e: errorMsg = e.args[0] for subString, exceptionClass in klass.exceptionStrMap.iteritems(): if subString in errorMsg: raise exceptionClass(e) else: raise UnknownDatabaseError(e)
def main(): print "Begin" db = xapian.WritableDatabase(xapian.open('test.db', xapian.DB_CREATE_OR_OPEN)) index_data(db)