Logo Search packages:      
Sourcecode: zim version File versions  Download package

def zim::index::Index::update (   self,
  path = None,
  background = False,
  checkcontents = True,
  callback = None 
)

This method initiates a database update for a namespace, or,
if no path is given for the root namespace of the notebook. For
each path the indexkey as provided by the notebook store will be checked
to decide if an update is needed. Note that if we have a new index which
is still empty, updating will build the contents.

If "background" is True the update will be scheduled on idle events
in the glib / gtk main loop. Starting a second background job while
one is already running just adds the new path in the queue.

If "checkcontents" is True the indexkey for each page is checked to
determine if the contents also need to be indexed. If this option
is False only pagelists will be updated. Any new pages that are
encoutered are always indexed fully regardless of this option.

A callback method can be supplied that will be called after each
updated path. This can be used e.g. to display a progress bar. the
callback gets the path just processed as an argument. If the callback
returns False the update will not continue.

Indexes are checked width first. This is important to make the visual
behavior of treeviews displaying the index look more solid.

Definition at line 333 of file index.py.

00333                                                                                       :
            '''This method initiates a database update for a namespace, or,
            if no path is given for the root namespace of the notebook. For
            each path the indexkey as provided by the notebook store will be checked
            to decide if an update is needed. Note that if we have a new index which
            is still empty, updating will build the contents.

            If "background" is True the update will be scheduled on idle events
            in the glib / gtk main loop. Starting a second background job while
            one is already running just adds the new path in the queue.

            If "checkcontents" is True the indexkey for each page is checked to
            determine if the contents also need to be indexed. If this option
            is False only pagelists will be updated. Any new pages that are
            encoutered are always indexed fully regardless of this option.

            A callback method can be supplied that will be called after each
            updated path. This can be used e.g. to display a progress bar. the
            callback gets the path just processed as an argument. If the callback
            returns False the update will not continue.

            Indexes are checked width first. This is important to make the visual
            behavior of treeviews displaying the index look more solid.
            '''

            # Updating uses two queues, one for indexing the tree structure and a
            # second for pages where we need to index the content. Reason is that we
            # first need to have the full tree before we can reliably resolve links
            # and thus index content.

            if path is None:
                  path = Path(':')

            indexpath = self.lookup_path(path)
            if indexpath is None:
                  indexpath = self.touch(path)
                  indexpath._row['haschildren'] = True
                  indexpath._row['childrenkey'] = None
                  checkcontent = True

            self._flush_queue(path)
            self._update_pagelist_queue.append(indexpath)
            if checkcontents and not indexpath.isroot:
                  self._index_page_queue.append(indexpath)

            if not self.updating:
                  self.emit('start-update')

            if background:
                  if not self.updating:
                        # Start new queue
                        logger.info('Starting background index update')
                        self.updating = True
                        self._checkcontents = checkcontents
                        gobject.idle_add(self._do_update, (checkcontents, callback))
                  # Else let running queue pick it up
            else:
                  logger.info('Updating index')
                  if self.updating:
                        checkcontents = checkcontents or self._checkcontents
                  while self._do_update((checkcontents, callback)):
                        continue

      def ensure_update(self, callback=None):


Generated by  Doxygen 1.6.0   Back to index