Пример #1
0
	def _set_disk_cpc(self, page, plist):
		if not rendcache.cache_on(self.cfg) or page.virtual() or \
		   page.type != "dir":
			return
		v = rendcache.Validator()
		v.add_mtime(page)
		ds = {page.path: True}
		# note that Storage .children() (and thus .descendants()
		# et al) never returns directories. This is a bit
		# regrettable.
		for ts, ppath in plist:
			pdir = utils.parent_path(ppath)
			if pdir in ds:
				continue
			ds[pdir] = True
			v.add_mtime(self.model.get_page(pdir))
		rendcache.store_gen(self, "page-kids", page.path, plist, v)
Пример #2
0
 def _set_disk_cpc(self, page, plist):
     if not rendcache.cache_on(self.cfg) or page.virtual() or \
        page.type != "dir":
         return
     v = rendcache.Validator()
     v.add_mtime(page)
     ds = {page.path: True}
     # note that Storage .children() (and thus .descendants()
     # et al) never returns directories. This is a bit
     # regrettable.
     for ts, ppath in plist:
         pdir = utils.parent_path(ppath)
         if pdir in ds:
             continue
         ds[pdir] = True
         v.add_mtime(self.model.get_page(pdir))
     rendcache.store_gen(self, "page-kids", page.path, plist, v)
Пример #3
0
def gen_pnpages(context, vdir):
	# Disabled? Skip entirely.
	if not rendcache.gen_cache_on(context.cfg):
		return gen_pnp_direct(context, vdir)

	# Even if we get a cache hit, we must super-validate it. We do so
	# by checking that the timestamps of ourselves and our next and
	# previous links are the same as in the list.
	res = rendcache.fetch_gen(context, vdir.path, 'pnc-kids')
	if res:
		r = steppage_pos(context, context.page.path, res)
		if r and \
		   valid_pos(context, res, r[0]) and \
		   valid_pos(context, res, r[1]) and \
		   valid_pos(context, res, r[2]):
			return pages_from_pos(context, res, r)

	# Miss; generate.
	r = gen_pnp_direct(context, vdir)
	if not r:
		return r
	dl = r[2]

	# The validator for the list is somewhat big; it is the timestamp
	# of every directory in the list, explicitly including the root
	# of the list. Unfortunately we have to manually deduce this from
	# the files in the list, which means that we can accidentally
	# omit a directory that currently has no files. This is really
	# a fault of the cache_page_children() approach, but meh.
	v = rendcache.Validator()
	ds = {}
	v.add_mtime(vdir)
	ds[vdir.path] = True
	for ts, ppath in dl:
		pdir = utils.parent_path(ppath)
		if pdir in ds:
			continue
		ds[pdir] = True
		v.add_mtime(context.model.get_page(pdir))
	rendcache.store_gen(context, 'pnc-kids', vdir.path, dl, v)
	return r
Пример #4
0
	def parent(self):
		if self.path == '':
			return self
		else:
			return self._get(utils.parent_path(self.path))
Пример #5
0
	def comments_children(self, page):
		if not self.comments_on():
			return
		for i in self.cstore.children(page.path):
			yield (i[0], utils.parent_path(i[1]),
			       utils.name_path(i[1]))