Example #1
0
	def _restrictable(self, optlist):
		if 'atomfeed-virt-only-in' not in self.context or \
		   not self.page.virtual() or \
		   not pageranges.is_restriction(self.context) or \
		   pageranges.restriction(self.context) in optlist:
			return False
		return True
Example #2
0
 def _restrictable(self, optlist):
     if 'atomfeed-virt-only-in' not in self.context or \
        not self.page.virtual() or \
        not pageranges.is_restriction(self.context) or \
        pageranges.restriction(self.context) in optlist:
         return False
     return True
Example #3
0
def isblogyearmonth(context):
    """Suceeds (by generating a space) if we are a directory, in a
	blog view, and we are in a month or year VirtualDirectory.
	Fails otherwise."""
    if context.view != "blog" or \
       not pageranges.is_restriction(context) or \
       pageranges.restriction(context) not in ('year', 'month'):
        return ''
    else:
        return ' '
Example #4
0
def clipDown(context, dl):
	if 'blog-display-howmany' in context:
		cutpoint = context['blog-display-howmany']
	else:
		cutpoint = TOPN_NUMBER
	if len(dl) > cutpoint and \
	   (not pageranges.is_restriction(context) or \
	    pageranges.restriction(context) in ('year', 'month')):
		t1 = time.localtime(dl[cutpoint-1][0])
		i = cutpoint
		while i < len(dl):
			t2 = time.localtime(dl[i][0])
			if t1.tm_mday != t2.tm_mday:
				break
			i += 1
		if i < len(dl):
			context.setvar(":blog:clippedrange", dl[i])
			context.setvar(":blog:clipsize", i)
			dl = dl[:i]
	return dl
Example #5
0
def clipDown(context, dl):
    if 'blog-display-howmany' in context:
        cutpoint = context['blog-display-howmany']
    else:
        cutpoint = TOPN_NUMBER
    if len(dl) > cutpoint and \
       (not pageranges.is_restriction(context) or \
        pageranges.restriction(context) in ('year', 'month')):
        t1 = time.localtime(dl[cutpoint - 1][0])
        i = cutpoint
        while i < len(dl):
            t2 = time.localtime(dl[i][0])
            if t1.tm_mday != t2.tm_mday:
                break
            i += 1
        if i < len(dl):
            context.setvar(":blog:clippedrange", dl[i])
            context.setvar(":blog:clipsize", i)
            dl = dl[:i]
    return dl
Example #6
0
def true_atom_page(context, only_in=False):
    if not context.page.virtual() or \
       not pageranges.is_restriction(context) or \
       not ('atomfeed-virt-only-in' in context or \
     'atomfeed-virt-only-adv' in context):
        # We must use .curdir() here because hasatomfeed() is
        # true for the root page as well as directories.
        return context.page.curdir()
    # tricky: .curdir() is not necessary now since virtual pages are
    # always directories.
    rt = pageranges.restriction(context)
    # If we are called with only_in True, a-v-only-in is known to exist.
    if only_in:
        atypes = context['atomfeed-virt-only-in']
    else:
        atypes = context.get('atomfeed-virt-only-adv',
                             context.get('atomfeed-virt-only-in', None))
    if rt in atypes or \
       (rt in ('year', 'month', 'day') and 'calendar' in atypes):
        return context.page
    return context.page.me()
Example #7
0
def true_atom_page(context, only_in = False):
	if not context.page.virtual() or \
	   not pageranges.is_restriction(context) or \
	   not ('atomfeed-virt-only-in' in context or \
		'atomfeed-virt-only-adv' in context):
		# We must use .curdir() here because hasatomfeed() is
		# true for the root page as well as directories.
		return context.page.curdir()
	# tricky: .curdir() is not necessary now since virtual pages are
	# always directories.
	rt = pageranges.restriction(context)
	# If we are called with only_in True, a-v-only-in is known to exist.
	if only_in:
		atypes = context['atomfeed-virt-only-in']
	else:
		atypes = context.get('atomfeed-virt-only-adv',
				     context.get('atomfeed-virt-only-in', None))
	if rt in atypes or \
	   (rt in ('year', 'month', 'day') and 'calendar' in atypes):
		return context.page
	return context.page.me()