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
def _get_disk_cpc(self, page): if not rendcache.cache_on(self.cfg) or page.virtual() or \ page.type != "dir": return None return rendcache.fetch_gen(self, page.path, "page-kids")