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

def zim::index::Index::touch (   self,
  path 
)

This method creates a path along with all it's parents.
Returns the final IndexPath. Path is created as a palceholder which
has neither content or children.

Definition at line 449 of file index.py.

00449                            :
            '''This method creates a path along with all it's parents.
            Returns the final IndexPath. Path is created as a palceholder which
            has neither content or children.
            '''
            with self.db_commit:
                  cursor = self.db.cursor()
                  names = path.parts
                  parentid = ROOT_ID
                  indexpath = [ROOT_ID]
                  inserted = [] # newly inserted paths
                  lastparent = None # last parent that already existed
                  for i in range(len(names)):
                        p = self.lookup_path(Path(names[:i+1]))
                        if p is None:
                              haschildren = i < (len(names) - 1)
                              cursor.execute(
                                    'insert into pages(basename, parent, hascontent, haschildren) values (?, ?, ?, ?)',
                                    (names[i], parentid, False, haschildren))
                              parentid = cursor.lastrowid
                              indexpath.append(parentid)
                              inserted.append(
                                    IndexPath(':'.join(names[:i+1]), indexpath,
                                          {'hascontent': False, 'haschildren': haschildren}))
                        else:
                              lastparent = p
                              parentid = p.id
                              indexpath.append(parentid)

                  if lastparent and not lastparent.haschildren:
                        self.db.execute('update pages set haschildren = ? where id == ?', (True, lastparent.id))
                  else:
                        lastparent = None

            if lastparent:
                  self.emit('page-haschildren-toggled', lastparent)

            for path in inserted:
                  self.emit('page-inserted', path)

            if inserted:
                  return inserted[-1]
            else:
                  return self.lookup_path(path)

      def _index_page(self, path, page):


Generated by  Doxygen 1.6.0   Back to index