示例#1
0
    def __init__(self, blocks):
        tname, args, section = blocks[0]
        self.__name__ = args
        self.section = section.blocks
        self.args = args = parse_let_params(args)

        for i in range(len(args)):
            name, expr = args[i]
            if expr[:1] == '"' and expr[-1:] == '"' and len(expr) > 1:
                # expr shorthand
                expr = expr[1:-1]
                try:
                    args[i] = name, Eval(expr, expr_globals).eval
                except SyntaxError, v:
                    m, (huh, l, c, src) = v
                    raise ParseError, (
                        '<strong>Expression (Python) Syntax error</strong>:'
                        '\n<pre>\n%s\n</pre>\n' % v[0], 'let')
示例#2
0
    def __init__(self, blocks):
        tname, args, section = blocks[0]
        args = parse_params(args,
                            name='',
                            start='1',
                            end='-1',
                            size='10',
                            orphan='0',
                            overlap='1',
                            mapping=1,
                            no_push_item=1,
                            skip_unauthorized=1,
                            previous=1,
                            next=1,
                            expr='',
                            sort='',
                            reverse=1,
                            sort_expr='',
                            reverse_expr='',
                            prefix='')
        self.args = args
        has_key = args.has_key

        if has_key('sort'):
            self.sort = sort = args['sort']
            if sort == 'sequence-item': self.sort = ''

        if has_key('sort_expr'):
            self.sort_expr = Eval(args['sort_expr'])

        if has_key('reverse_expr'):
            self.reverse_expr = Eval(args['reverse_expr'])

        if has_key('reverse'):
            self.reverse = args['reverse']

        if has_key('no_push_item'):
            self.no_push_item = args['no_push_item']

        if has_key('mapping'): self.mapping = args['mapping']
        for n in 'start', 'size', 'end':
            if has_key(n): self.batch = 1

        prefix = args.get('prefix')
        if prefix and not simple_name(prefix):
            raise ParseError, _tm('prefix is not a simple name', 'in')

        for n in 'orphan', 'overlap', 'previous', 'next':
            if has_key(n) and not self.batch:
                raise ParseError, ("""
                    The %s attribute was used but neither of the
                    <code>start</code>, <code>end</code>, or <code>size</code>
                    attributes were used.
                    """ % n, 'in')

        if has_key('start'):
            v = args['start']
            if type(v) == type(''):
                try:
                    int(v)
                except:

                    self.start_name_re = re.compile(
                        '&+' + ''.join(["[%s]" % c for c in v]) + '=[0-9]+&+')

        name, expr = name_param(args, 'in', 1)
        if expr is not None: expr = expr.eval
        self.__name__, self.expr = name, expr
        self.section = section.blocks
        if len(blocks) > 1:
            if len(blocks) != 2:
                raise ParseError, ('too many else blocks', 'in')
            tname, args, section = blocks[1]
            args = parse_params(args, name='')
            if args:
                ename = name_param(args)
                if ename != name:
                    raise ParseError, ('name in else does not match in', 'in')
            self.elses = section.blocks
示例#3
0
    def __init__(self, blocks):
        tname, args, section = blocks[0]
        args=parse_params(args, name='', start='1',end='-1',size='10',
                          orphan='0',overlap='1',mapping=1,
                          no_push_item=1,
                          skip_unauthorized=1,
                          previous=1, next=1, expr='', sort='',
                          reverse=1, sort_expr='', reverse_expr='',
                          prefix='')
        self.args=args
        has_key=args.has_key

        if has_key('sort'):
            self.sort=sort=args['sort']
            if sort=='sequence-item': self.sort=''

        if has_key('sort_expr'):
            self.sort_expr=Eval(args['sort_expr'])

        if has_key('reverse_expr'):
            self.reverse_expr=Eval(args['reverse_expr'])

        if has_key('reverse'):
            self.reverse=args['reverse']

        if has_key('no_push_item'):
            self.no_push_item=args['no_push_item']

        if has_key('mapping'): self.mapping=args['mapping']
        for n in 'start', 'size', 'end':
            if has_key(n): self.batch=1

        prefix = args.get('prefix')
        if prefix and not simple_name(prefix):
            raise ParseError, _tm(
                'prefix is not a simple name', 'in')

        for n in 'orphan','overlap','previous','next':
            if has_key(n) and not self.batch:
                raise ParseError, (
                    """
                    The %s attribute was used but neither of the
                    <code>start</code>, <code>end</code>, or <code>size</code>
                    attributes were used.
                    """ % n, 'in')

        if has_key('start'):
            v=args['start']
            if type(v)==type(''):
                try: int(v)
                except:

                    self.start_name_re=re.compile(
                        '&+'+
                        ''.join(["[%s]" % c for c in v])+
                        '=[0-9]+&+')

        name,expr=name_param(args,'in',1)
        if expr is not None: expr=expr.eval
        self.__name__, self.expr = name, expr
        self.section=section.blocks
        if len(blocks) > 1:
            if len(blocks) != 2: raise ParseError, (
                'too many else blocks', 'in')
            tname, args, section = blocks[1]
            args=parse_params(args, name='')
            if args:
                ename=name_param(args)
                if ename != name:
                    raise ParseError, (
                        'name in else does not match in', 'in')
            self.elses=section.blocks
示例#4
0
class InClass:
    elses = None
    expr = sort = batch = mapping = no_push_item = None
    start_name_re = None
    reverse = None
    sort_expr = reverse_expr = None

    def __init__(self, blocks):
        tname, args, section = blocks[0]
        args = parse_params(args,
                            name='',
                            start='1',
                            end='-1',
                            size='10',
                            orphan='0',
                            overlap='1',
                            mapping=1,
                            no_push_item=1,
                            skip_unauthorized=1,
                            previous=1,
                            next=1,
                            expr='',
                            sort='',
                            reverse=1,
                            sort_expr='',
                            reverse_expr='',
                            prefix='')
        self.args = args
        has_key = args.has_key

        if has_key('sort'):
            self.sort = sort = args['sort']
            if sort == 'sequence-item': self.sort = ''

        if has_key('sort_expr'):
            self.sort_expr = Eval(args['sort_expr'])

        if has_key('reverse_expr'):
            self.reverse_expr = Eval(args['reverse_expr'])

        if has_key('reverse'):
            self.reverse = args['reverse']

        if has_key('no_push_item'):
            self.no_push_item = args['no_push_item']

        if has_key('mapping'): self.mapping = args['mapping']
        for n in 'start', 'size', 'end':
            if has_key(n): self.batch = 1

        prefix = args.get('prefix')
        if prefix and not simple_name(prefix):
            raise ParseError, _tm('prefix is not a simple name', 'in')

        for n in 'orphan', 'overlap', 'previous', 'next':
            if has_key(n) and not self.batch:
                raise ParseError, ("""
                    The %s attribute was used but neither of the
                    <code>start</code>, <code>end</code>, or <code>size</code>
                    attributes were used.
                    """ % n, 'in')

        if has_key('start'):
            v = args['start']
            if type(v) == type(''):
                try:
                    int(v)
                except:

                    self.start_name_re = re.compile(
                        '&+' + ''.join(["[%s]" % c for c in v]) + '=[0-9]+&+')

        name, expr = name_param(args, 'in', 1)
        if expr is not None: expr = expr.eval
        self.__name__, self.expr = name, expr
        self.section = section.blocks
        if len(blocks) > 1:
            if len(blocks) != 2:
                raise ParseError, ('too many else blocks', 'in')
            tname, args, section = blocks[1]
            args = parse_params(args, name='')
            if args:
                ename = name_param(args)
                if ename != name:
                    raise ParseError, ('name in else does not match in', 'in')
            self.elses = section.blocks

    def renderwb(self, md):
        expr = self.expr
        name = self.__name__
        if expr is None:
            sequence = md[name]
            cache = {name: sequence}
        else:
            sequence = expr(md)
            cache = None

        if not sequence:
            if self.elses: return render_blocks(self.elses, md)
            return ''

        if type(sequence) is type(''):
            raise ValueError, (
                'Strings are not allowed as input to the in tag.')

        section = self.section
        params = self.args

        mapping = self.mapping
        no_push_item = self.no_push_item

        if self.sort_expr is not None:
            self.sort = self.sort_expr.eval(md)
            sequence = self.sort_sequence(sequence, md)
        elif self.sort is not None:
            sequence = self.sort_sequence(sequence, md)

        if self.reverse_expr is not None and self.reverse_expr.eval(md):
            sequence = self.reverse_sequence(sequence)
        elif self.reverse is not None:
            sequence = self.reverse_sequence(sequence)

        next = previous = 0
        try:
            start = int_param(params, md, 'start', 0)
        except:
            start = 1
        end = int_param(params, md, 'end', 0)
        size = int_param(params, md, 'size', 0)
        overlap = int_param(params, md, 'overlap', 0)
        orphan = int_param(params, md, 'orphan', '0')
        start, end, sz = opt(start, end, size, orphan, sequence)
        if params.has_key('next'): next = 1
        if params.has_key('previous'): previous = 1

        last = end - 1
        first = start - 1

        try:
            query_string = md['QUERY_STRING']
        except:
            query_string = ''
        prefix = params.get('prefix')
        vars = sequence_variables(sequence, '?' + query_string,
                                  self.start_name_re, prefix)
        kw = vars.data
        pkw = add_with_prefix(kw, 'sequence', prefix)
        for k, v in kw.items():
            pkw[k] = v
        pkw['sequence-step-size'] = sz
        pkw['sequence-step-overlap'] = overlap
        pkw['sequence-step-start'] = start
        pkw['sequence-step-end'] = end
        pkw['sequence-step-start-index'] = start - 1
        pkw['sequence-step-end-index'] = end - 1
        pkw['sequence-step-orphan'] = orphan

        kw['mapping'] = mapping

        push = md._push
        pop = md._pop
        render = render_blocks

        if cache: push(cache)
        push(vars)
        try:
            if previous:
                if first > 0:
                    pstart, pend, psize = opt(0, first + overlap, sz, orphan,
                                              sequence)
                    pkw['previous-sequence'] = 1
                    pkw['previous-sequence-start-index'] = pstart - 1
                    pkw['previous-sequence-end-index'] = pend - 1
                    pkw['previous-sequence-size'] = pend + 1 - pstart
                    result = render(section, md)

                elif self.elses:
                    result = render(self.elses, md)
                else:
                    result = ''
            elif next:
                try:
                    # The following line is a sneaky way to test whether
                    # there are more items, without actually
                    # computing a length:
                    sequence[end]
                except IndexError:
                    if self.elses: result = render(self.elses, md)
                    else: result = ''
                else:
                    pstart, pend, psize = opt(end + 1 - overlap, 0, sz, orphan,
                                              sequence)
                    pkw['next-sequence'] = 1
                    pkw['next-sequence-start-index'] = pstart - 1
                    pkw['next-sequence-end-index'] = pend - 1
                    pkw['next-sequence-size'] = pend + 1 - pstart
                    result = render(section, md)
            else:
                result = []
                append = result.append
                guarded_getitem = getattr(md, 'guarded_getitem', None)
                for index in range(first, end):
                    # preset
                    pkw['previous-sequence'] = 0
                    pkw['next-sequence'] = 0  # now more often defined then previously
                    #
                    if index == first or index == last:
                        # provide batching information
                        if first > 0:
                            pstart, pend, psize = opt(0, first + overlap, sz,
                                                      orphan, sequence)
                            if index == first: pkw['previous-sequence'] = 1
                            pkw['previous-sequence-start-index'] = pstart - 1
                            pkw['previous-sequence-end-index'] = pend - 1
                            pkw['previous-sequence-size'] = pend + 1 - pstart
                        try:
                            # The following line is a sneaky way to
                            # test whether there are more items,
                            # without actually computing a length:
                            sequence[end]
                            pstart, pend, psize = opt(end + 1 - overlap, 0, sz,
                                                      orphan, sequence)
                            if index == last: pkw['next-sequence'] = 1
                            pkw['next-sequence-start-index'] = pstart - 1
                            pkw['next-sequence-end-index'] = pend - 1
                            pkw['next-sequence-size'] = pend + 1 - pstart
                        except:
                            pass

                    if index == last: pkw['sequence-end'] = 1

                    if guarded_getitem is not None:
                        try:
                            client = guarded_getitem(sequence, index)
                        except ValidationError, vv:
                            if (params.has_key('skip_unauthorized')
                                    and params['skip_unauthorized']):
                                if index == first: pkw['sequence-start'] = 0
                                continue
                            raise ValidationError, '(item %s): %s' % (
                                index, vv), sys.exc_info()[2]
                    else:
                        client = sequence[index]

                    pkw['sequence-index'] = index
                    t = type(client)
                    if t is TupleType and len(client) == 2:
                        client = client[1]

                    if no_push_item:
                        pushed = 0
                    elif mapping:
                        pushed = 1
                        push(client)
                    elif t in StringTypes:
                        pushed = 0
                    else:
                        pushed = 1
                        push(InstanceDict(client, md))

                    try:
                        append(render(section, md))
                    finally:
                        if pushed:
                            pop()

                    if index == first: pkw['sequence-start'] = 0

                result = join_unicode(result)

        finally:
            if cache: pop()
            pop()

        return result

    def renderwob(self, md):
        """RENDER WithOutBatch"""
        expr = self.expr
        name = self.__name__
        if expr is None:
            sequence = md[name]
            cache = {name: sequence}
        else:
            sequence = expr(md)
            cache = None

        if not sequence:
            if self.elses: return render_blocks(self.elses, md)
            return ''

        if type(sequence) is type(''):
            raise ValueError, (
                'Strings are not allowed as input to the in tag.')

        section = self.section
        mapping = self.mapping
        no_push_item = self.no_push_item

        if self.sort_expr is not None:
            self.sort = self.sort_expr.eval(md)
            sequence = self.sort_sequence(sequence, md)
        elif self.sort is not None:
            sequence = self.sort_sequence(sequence, md)

        if self.reverse_expr is not None and self.reverse_expr.eval(md):
            sequence = self.reverse_sequence(sequence)
        elif self.reverse is not None:
            sequence = self.reverse_sequence(sequence)

        prefix = self.args.get('prefix')
        vars = sequence_variables(sequence, alt_prefix=prefix)
        kw = vars.data
        pkw = add_with_prefix(kw, 'sequence', prefix)
        for k, v in kw.items():
            pkw[k] = v
        kw['mapping'] = mapping

        l = len(sequence)
        last = l - 1

        push = md._push
        pop = md._pop
        render = render_blocks

        if cache: push(cache)
        push(vars)
        try:
            result = []
            append = result.append
            guarded_getitem = getattr(md, 'guarded_getitem', None)
            for index in range(l):
                if index == last: pkw['sequence-end'] = 1
                if guarded_getitem is not None:
                    try:
                        client = guarded_getitem(sequence, index)
                    except ValidationError, vv:
                        if (self.args.has_key('skip_unauthorized')
                                and self.args['skip_unauthorized']):
                            if index == 1: pkw['sequence-start'] = 0
                            continue
                        raise ValidationError, '(item %s): %s' % (
                            index, vv), sys.exc_info()[2]
                else:
                    client = sequence[index]

                pkw['sequence-index'] = index
                t = type(client)
                if t is TupleType and len(client) == 2:
                    client = client[1]

                if no_push_item:
                    pushed = 0
                elif mapping:
                    pushed = 1
                    push(client)
                elif t in StringTypes:
                    pushed = 0
                else:
                    pushed = 1
                    push(InstanceDict(client, md))

                try:
                    append(render(section, md))
                finally:
                    if pushed:
                        pop()
                if index == 0: pkw['sequence-start'] = 0

            result = join_unicode(result)

        finally:
示例#5
0
class InClass:
    elses=None
    expr=sort=batch=mapping=no_push_item=None
    start_name_re=None
    reverse=None
    sort_expr=reverse_expr=None

    def __init__(self, blocks):
        tname, args, section = blocks[0]
        args=parse_params(args, name='', start='1',end='-1',size='10',
                          orphan='0',overlap='1',mapping=1,
                          no_push_item=1,
                          skip_unauthorized=1,
                          previous=1, next=1, expr='', sort='',
                          reverse=1, sort_expr='', reverse_expr='',
                          prefix='')
        self.args=args
        has_key=args.has_key

        if has_key('sort'):
            self.sort=sort=args['sort']
            if sort=='sequence-item': self.sort=''

        if has_key('sort_expr'):
            self.sort_expr=Eval(args['sort_expr'])

        if has_key('reverse_expr'):
            self.reverse_expr=Eval(args['reverse_expr'])

        if has_key('reverse'):
            self.reverse=args['reverse']

        if has_key('no_push_item'):
            self.no_push_item=args['no_push_item']

        if has_key('mapping'): self.mapping=args['mapping']
        for n in 'start', 'size', 'end':
            if has_key(n): self.batch=1

        prefix = args.get('prefix')
        if prefix and not simple_name(prefix):
            raise ParseError, _tm(
                'prefix is not a simple name', 'in')

        for n in 'orphan','overlap','previous','next':
            if has_key(n) and not self.batch:
                raise ParseError, (
                    """
                    The %s attribute was used but neither of the
                    <code>start</code>, <code>end</code>, or <code>size</code>
                    attributes were used.
                    """ % n, 'in')

        if has_key('start'):
            v=args['start']
            if type(v)==type(''):
                try: int(v)
                except:

                    self.start_name_re=re.compile(
                        '&+'+
                        ''.join(["[%s]" % c for c in v])+
                        '=[0-9]+&+')

        name,expr=name_param(args,'in',1)
        if expr is not None: expr=expr.eval
        self.__name__, self.expr = name, expr
        self.section=section.blocks
        if len(blocks) > 1:
            if len(blocks) != 2: raise ParseError, (
                'too many else blocks', 'in')
            tname, args, section = blocks[1]
            args=parse_params(args, name='')
            if args:
                ename=name_param(args)
                if ename != name:
                    raise ParseError, (
                        'name in else does not match in', 'in')
            self.elses=section.blocks


    def renderwb(self, md):
        expr=self.expr
        name=self.__name__
        if expr is None:
            sequence=md[name]
            cache={ name: sequence }
        else:
            sequence=expr(md)
            cache=None

        if not sequence:
            if self.elses: return render_blocks(self.elses, md)
            return ''

        if type(sequence) is type(''):
            raise 'InError', (
                'Strings are not allowed as input to the in tag.')


        section=self.section
        params=self.args

        mapping=self.mapping
        no_push_item=self.no_push_item

        if self.sort_expr is not None:
            self.sort=self.sort_expr.eval(md)
            sequence=self.sort_sequence(sequence, md)
        elif self.sort is not None:
            sequence=self.sort_sequence(sequence, md)

        if self.reverse_expr is not None and self.reverse_expr.eval(md):
            sequence=self.reverse_sequence(sequence)
        elif self.reverse is not None:
            sequence=self.reverse_sequence(sequence)

        next=previous=0
        try: start=int_param(params,md,'start',0)
        except: start=1
        end=int_param(params,md,'end',0)
        size=int_param(params,md,'size',0)
        overlap=int_param(params,md,'overlap',0)
        orphan=int_param(params,md,'orphan','0')
        start,end,sz=opt(start,end,size,orphan,sequence)
        if params.has_key('next'): next=1
        if params.has_key('previous'): previous=1

        last=end-1
        first=start-1

        try: query_string=md['QUERY_STRING']
        except: query_string=''
        prefix = params.get('prefix')
        vars = sequence_variables(sequence, '?'+query_string,
                                  self.start_name_re, prefix)
        kw=vars.data
        pkw = add_with_prefix(kw, 'sequence', prefix)
        for k, v in kw.items():
            pkw[k] = v
        pkw['sequence-step-size']=sz
        pkw['sequence-step-overlap']=overlap
        pkw['sequence-step-start']=start
        pkw['sequence-step-end']=end
        pkw['sequence-step-start-index']=start-1
        pkw['sequence-step-end-index']=end-1
        pkw['sequence-step-orphan']=orphan

        kw['mapping']=mapping

        push=md._push
        pop=md._pop
        render=render_blocks

        if cache: push(cache)
        push(vars)
        try:
            if previous:
                if first > 0:
                    pstart,pend,psize=opt(0,first+overlap,
                                          sz,orphan,sequence)
                    pkw['previous-sequence']=1
                    pkw['previous-sequence-start-index']=pstart-1
                    pkw['previous-sequence-end-index']=pend-1
                    pkw['previous-sequence-size']=pend+1-pstart
                    result=render(section,md)

                elif self.elses: result=render(self.elses, md)
                else: result=''
            elif next:
                try:
                    # The following line is a sneaky way to test whether
                    # there are more items, without actually
                    # computing a length:
                    sequence[end]
                except IndexError:
                    if self.elses: result=render(self.elses, md)
                    else: result=''
                else:
                    pstart,pend,psize=opt(end+1-overlap,0,
                                          sz,orphan,sequence)
                    pkw['next-sequence']=1
                    pkw['next-sequence-start-index']=pstart-1
                    pkw['next-sequence-end-index']=pend-1
                    pkw['next-sequence-size']=pend+1-pstart
                    result=render(section,md)
            else:
                result = []
                append=result.append
                guarded_getitem = getattr(md, 'guarded_getitem', None)
                for index in range(first,end):
                    # preset
                    pkw['previous-sequence']= 0
                    pkw['next-sequence']= 0 # now more often defined then previously
                    #
                    if index==first or index==last:
                        # provide batching information
                        if first > 0:
                            pstart,pend,psize=opt(0,first+overlap,
                                                  sz,orphan,sequence)
                            if index==first: pkw['previous-sequence']=1
                            pkw['previous-sequence-start-index']=pstart-1
                            pkw['previous-sequence-end-index']=pend-1
                            pkw['previous-sequence-size']=pend+1-pstart
                        try:
                            # The following line is a sneaky way to
                            # test whether there are more items,
                            # without actually computing a length:
                            sequence[end]
                            pstart,pend,psize=opt(end+1-overlap,0,
                                                  sz,orphan,sequence)
                            if index==last: pkw['next-sequence']=1
                            pkw['next-sequence-start-index']=pstart-1
                            pkw['next-sequence-end-index']=pend-1
                            pkw['next-sequence-size']=pend+1-pstart
                        except: pass

                    if index==last: pkw['sequence-end']=1

                    if guarded_getitem is not None:
                        try: client = guarded_getitem(sequence, index)
                        except ValidationError, vv:
                            if (params.has_key('skip_unauthorized') and
                                params['skip_unauthorized']):
                                if index==first: pkw['sequence-start']=0
                                continue
                            raise ValidationError, '(item %s): %s' % (
                                index, vv), sys.exc_info()[2]
                    else:
                        client = sequence[index]

                    pkw['sequence-index']=index
                    t = type(client)
                    if t is TupleType and len(client)==2:
                        client=client[1]

                    if no_push_item:
                        pushed = 0
                    elif mapping:
                        pushed = 1
                        push(client)
                    elif t in StringTypes:
                        pushed = 0
                    else:
                        pushed = 1
                        push(InstanceDict(client, md))

                    try: append(render(section, md))
                    finally:
                        if pushed:
                            pop()

                    if index==first: pkw['sequence-start']=0


                result = join_unicode(result)

        finally:
            if cache: pop()
            pop()

        return result

    def renderwob(self, md):
        """RENDER WithOutBatch"""
        expr=self.expr
        name=self.__name__
        if expr is None:
            sequence=md[name]
            cache={ name: sequence }
        else:
            sequence=expr(md)
            cache=None

        if not sequence:
            if self.elses: return render_blocks(self.elses, md)
            return ''

        if type(sequence) is type(''):
            raise 'InError', (
                'Strings are not allowed as input to the in tag.')

        section=self.section
        mapping=self.mapping
        no_push_item=self.no_push_item

        if self.sort_expr is not None:
            self.sort=self.sort_expr.eval(md)
            sequence=self.sort_sequence(sequence, md)
        elif self.sort is not None:
            sequence=self.sort_sequence(sequence, md)

        if self.reverse_expr is not None and self.reverse_expr.eval(md):
            sequence=self.reverse_sequence(sequence)
        elif self.reverse is not None:
            sequence=self.reverse_sequence(sequence)

        prefix = self.args.get('prefix')
        vars=sequence_variables(sequence, alt_prefix=prefix)
        kw=vars.data
        pkw = add_with_prefix(kw, 'sequence', prefix)
        for k, v in kw.items():
            pkw[k] = v
        kw['mapping']=mapping

        l=len(sequence)
        last=l-1

        push=md._push
        pop=md._pop
        render=render_blocks

        if cache: push(cache)
        push(vars)
        try:
            result = []
            append=result.append
            guarded_getitem = getattr(md, 'guarded_getitem', None)
            for index in range(l):
                if index==last: pkw['sequence-end']=1
                if guarded_getitem is not None:
                    try: client = guarded_getitem(sequence, index)
                    except ValidationError, vv:
                        if (self.args.has_key('skip_unauthorized') and
                            self.args['skip_unauthorized']):
                            if index==1: pkw['sequence-start']=0
                            continue
                        raise ValidationError, '(item %s): %s' % (
                            index, vv), sys.exc_info()[2]
                else:
                    client = sequence[index]

                pkw['sequence-index']=index
                t = type(client)
                if t is TupleType and len(client)==2:
                    client=client[1]

                if no_push_item:
                    pushed = 0
                elif mapping:
                    pushed = 1
                    push(client)
                elif t in StringTypes:
                    pushed = 0
                else:
                    pushed = 1
                    push(InstanceDict(client, md))

                try: append(render(section, md))
                finally:
                    if pushed:
                        pop()
                if index==0: pkw['sequence-start']=0

            result = join_unicode(result)

        finally: