Django

Code

Show
Ignore:
Timestamp:
06/26/08 10:11:55 (7 months ago)
Author:
jbronn
Message:

gis: Merged revisions 7643-7662,7667-7668,7672-7682,7686-7693,7695-7698,7700-7702,7704-7706,7710,7712-7729,7731-7732,7738-7758,7760-7766 via svnmerge from trunk.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/gis

    • Property svnmerge-integrated changed from /django/trunk:1-7641 to /django/trunk:1-7767
  • django/branches/gis/django/template/defaulttags.py

    r7573 r7768  
    4040class CycleNode(Node): 
    4141    def __init__(self, cyclevars, variable_name=None): 
    42         self.cycle_iter = itertools_cycle(cyclevars
     42        self.cycle_iter = itertools_cycle([Variable(v) for v in cyclevars]
    4343        self.variable_name = variable_name 
    4444 
    4545    def render(self, context): 
    46         value = self.cycle_iter.next() 
    47         value = Variable(value).resolve(context) 
     46        value = self.cycle_iter.next().resolve(context) 
    4847        if self.variable_name: 
    4948            context[self.variable_name] = value 
     
    163162        self._last_seen = None 
    164163        self._varlist = map(Variable, varlist) 
    165  
    166     def render(self, context): 
    167         if 'forloop' in context and context['forloop']['first']: 
     164        self._id = str(id(self)) 
     165 
     166    def render(self, context): 
     167        if 'forloop' in context and self._id not in context['forloop']: 
    168168            self._last_seen = None 
     169            context['forloop'][self._id] = 1 
    169170        try: 
    170171            if self._varlist: 
     
    453454            <tr class="{% cycle rowcolors %}">...</tr> 
    454455 
    455     You can use any number of values, seperated by spaces. Commas can also 
     456    You can use any number of values, separated by spaces. Commas can also 
    456457    be used to separate values; if a comma is used, the cycle values are 
    457458    interpreted as literal strings. 
     
    460461    # Note: This returns the exact same node on each {% cycle name %} call; 
    461462    # that is, the node object returned from {% cycle a b c as name %} and the 
    462     # one returned from {% cycle name %} are the exact same object. This 
     463    # one returned from {% cycle name %} are the exact same object. This 
    463464    # shouldn't cause problems (heh), but if it does, now you know. 
    464465    # 
    465     # Ugly hack warning: this stuffs the named template dict into parser so 
     466    # Ugly hack warning: This stuffs the named template dict into parser so 
    466467    # that names are only unique within each template (as opposed to using 
    467468    # a global variable, which would make cycle names have to be unique across 
     
    482483        name = args[1] 
    483484        if not hasattr(parser, '_namedCycleNodes'): 
    484             raise TemplateSyntaxError("No named cycles in template." 
    485                                       " '%s' is not defined" % name) 
     485            raise TemplateSyntaxError("No named cycles in template. '%s' is not defined" % name) 
    486486        if not name in parser._namedCycleNodes: 
    487487            raise TemplateSyntaxError("Named cycle '%s' does not exist" % name) 
     
    683683    """ 
    684684    The ``{% if %}`` tag evaluates a variable, and if that variable is "true" 
    685     (i.e. exists, is not empty, and is not a false boolean value) the contents 
    686     of the block are output:: 
     685    (i.e., exists, is not empty, and is not a false boolean value), the 
     686    contents of the block are output: 
     687 
     688    :: 
    687689 
    688690        {% if athlete_list %} 
  • django/branches/gis/django/template/loader_tags.py

    r7103 r7768  
    7070    def render(self, context): 
    7171        compiled_parent = self.get_parent(context) 
    72         pos = 0 
    73         while isinstance(compiled_parent.nodelist[pos], TextNode): 
    74             pos += 1 
    75         parent_is_child = isinstance(compiled_parent.nodelist[pos], ExtendsNode) 
    7672        parent_blocks = dict([(n.name, n) for n in compiled_parent.nodelist.get_nodes_by_type(BlockNode)]) 
    7773        for block_node in self.nodelist.get_nodes_by_type(BlockNode): 
     
    8480                # add this BlockNode to the parent's ExtendsNode nodelist, so 
    8581                # it'll be checked when the parent node's render() is called. 
    86                 if parent_is_child: 
    87                     compiled_parent.nodelist[pos].nodelist.append(block_node) 
     82 
     83                # Find out if the parent template has a parent itself 
     84                for node in compiled_parent.nodelist: 
     85                    if not isinstance(node, TextNode): 
     86                        # If the first non-text node is an extends, handle it. 
     87                        if isinstance(node, ExtendsNode): 
     88                            node.nodelist.append(block_node) 
     89                        # Extends must be the first non-text node, so once you find 
     90                        # the first non-text node you can stop looking.  
     91                        break 
    8892            else: 
    8993                # Keep any existing parents and add a new one. Used by BlockNode.