Пример #1
0
def cached_comments_children(context, spage):
	def _ck():
		return ("commentkids", spage.path)
	r = context.getcache(_ck())
	if r is not None:
		return r
	# We avoid a proliferation of small cache entries by skipping
	# the disk cache entirely for single-entry/page requests.
	if not rendcache.gen_cache_on(context.cfg) or spage.type == "file":
		r = list(context.model.comments_children(spage))
		context.setcache(_ck(), r)
		return r

	r = rendcache.get_flagged(context, "comments-kids", spage.path,
				  "comments-updated")
	if r:
		context.setcache(_ck(), r)
		return r
	r = list(context.model.comments_children(spage))
	v = rendcache.Validator()
	# TODO: actual validator? What would it be?
	rendcache.store_gen(context, "comments-kids", spage.path,
			    r, v)
	context.setcache(_ck(), r)
	return r
Пример #2
0
def cached_comments_children(context, spage):
    def _ck():
        return ("commentkids", spage.path)

    r = context.getcache(_ck())
    if r is not None:
        return r
    # We avoid a proliferation of small cache entries by skipping
    # the disk cache entirely for single-entry/page requests.
    if not rendcache.gen_cache_on(context.cfg) or spage.type == "file":
        r = list(context.model.comments_children(spage))
        context.setcache(_ck(), r)
        return r

    r = rendcache.get_flagged(context, "comments-kids", spage.path,
                              "comments-updated")
    if r:
        context.setcache(_ck(), r)
        return r
    r = list(context.model.comments_children(spage))
    v = rendcache.Validator()
    # TODO: actual validator? What would it be?
    rendcache.store_gen(context, "comments-kids", spage.path, r, v)
    context.setcache(_ck(), r)
    return r
Пример #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 comment_posted(context):
	if rendcache.gen_cache_on(context.cfg):
		rendcache.invalidate_flagged(context, "comments-updated")
Пример #5
0
def comment_posted(context):
    if rendcache.gen_cache_on(context.cfg):
        rendcache.invalidate_flagged(context, "comments-updated")