This bug was one of the reasons I tried Jinja2 templating engine for
my new application.

I didn't know that, but it seems Django templates are quite a mess:
http://lucumr.pocoo.org/2008/9/16/why-jinja-is-not-django-and-why-django-should-have-a-look-at-it

Jure

On Aug 14, 12:13 am, djidjadji <[email protected]> wrote:
> The reason is that a Django template is converted to a Node-tree and
> this Node-tree is executed/rendered when the template is evaluated.
> The Node's keep there state in between template renderings.
> The solution is to add a tag that resets the counters in the CycleNode
> instances.
>
> At the end of the (base) template call this tag
>
> {% resetcycle %}
>
> -----------------------
> from google.appengine.ext import webapp
> from django.template import Node
>
> register = webapp.template.create_template_register()
>
> class ResetCycleNode(Node):
>     def __init__(self, cyclenodes):
>         self.cyclenodes = cyclenodes
>
>     def render(self, context):
>         for c in self.cyclenodes.values():
>             c.counter = -1
>         return ''
>
> @register.tag
> def resetcycle(parser, token):
>     # if you need tag error checking have a look at the Django
> defaulttag.py file on how to do it
>     return ResetCycleNode(getattr(parser,'_namedCycleNodes',{}))
> ----------------------------------
>
> 2010/8/11 Joshua Smith <[email protected]>:
>
>
>
> > I've been living with this one for a long time.  My solution was to
> > artificially add an iteration to make sure it had the right modulus number
> > of rows.
> > On Aug 11, 2010, at 1:43 PM, Ikai L (Google) wrote:
>
> > Interesting bug. It shouldn't work this way. I'll take a look at this.
> > Can you accomplish the same thing using the span tag and just letting it
> > wrap?
>
> > On Wed, Aug 11, 2010 at 1:12 AM, Blixt <[email protected]> wrote:
>
> >> When using {% cycle first,second %} it would appear that its state is
> >> stored between requests. The first time, the results are first,
> >> second, first, second... and the second request is second, first,
> >> second, first... (there is an odd amount of items that are cycled.)
>
> >> Is this bug specific to Google App Engine? A Google search didn't seem
> >> to bring up any results mentioning it.
>
> >> For a live example, see:http://2.latest.simpleeditionsapp.appspot.com/
> >> Relevant code:
>
> >>http://github.com/littke/simpleeditions/blob/187c5ebf71ce1824acb28eb8...

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to