Re: [Django] #7430: Recursively iterating through a template's nodes

2 views
Skip to first unread message

Django

unread,
Sep 11, 2011, 5:57:27 PM9/11/11
to django-...@googlegroups.com
#7430: Recursively iterating through a template's nodes
-------------------------------------+-------------------------------------
Reporter: miracle2k | Owner: nobody
Type: Bug | Status: closed
Milestone: | Component: Template system
Version: SVN | Severity: Normal
Resolution: needsinfo | Keywords:
Triage Stage: Design | Has patch: 0
decision needed | Needs tests: 1
Needs documentation: 0 | Easy pickings: 0
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
Changes (by carljm):

* status: new => closed
* ui_ux: => 0
* resolution: => needsinfo
* easy: => 0


Comment:

Code changes require more practical justification than this. Feel free to
reopen with demonstration of a specific use case, the code that is
currently required to achieve it, and the code that would be possible with
a change to Django.

--
Ticket URL: <https://code.djangoproject.com/ticket/7430#comment:7>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 2, 2023, 6:19:11 AM2/2/23
to django-...@googlegroups.com
#7430: Recursively iterating through a template's nodes
-------------------------------------+-------------------------------------
Reporter: miracle2k | Owner: nobody
Type: Bug | Status: new
Component: Template system | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* status: closed => new
* resolution: needsinfo =>
* needs_tests: 1 => 0
* stage: Design decision needed => Ready for checkin


Comment:

As per a [https://github.com/django/django/pull/16473 much later report
via a PR], `Template.__iter__()` looks broken:

{{{
>>> from django.template import Template
>>> t = Template('Hello, world!')
>>> next(iter(t))
...
TypeError: 'TextNode' object is not iterable
}}}

> I don't recall whether this was by design. Does any Django code actually
*use* this iter behavior?

According to the test suite, it doesn't.

I think this can just be removed (as per the PR).

--
Ticket URL: <https://code.djangoproject.com/ticket/7430#comment:8>

Django

unread,
Feb 2, 2023, 6:19:26 AM2/2/23
to django-...@googlegroups.com
#7430: Recursively iterating through a template's nodes
-------------------------------------+-------------------------------------
Reporter: miracle2k | Owner: Anders
| Hovmöller
Type: Bug | Status: assigned

Component: Template system | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* owner: nobody => Anders Hovmöller
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/7430#comment:9>

Django

unread,
Feb 2, 2023, 7:04:25 AM2/2/23
to django-...@googlegroups.com
#7430: Recursively iterating through a template's nodes
-------------------------------------+-------------------------------------
Reporter: miracle2k | Owner: Anders
| Hovmöller
Type: Bug | Status: assigned
Component: Template system | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Anders Hovmöller):

Just FYI I have working code for walking the syntax tree:
https://github.com/boxed/okrand/blob/main/okrand/__init__.py#L262

It's... not ideal as it requires two monkey patches that I've found so
far. But I personally don't think having `__iter__` on stuff is very
useful. There are multiple child nodelists, so iter would be a little
weird honestly.

--
Ticket URL: <https://code.djangoproject.com/ticket/7430#comment:10>

Django

unread,
Feb 8, 2023, 5:18:12 AM2/8/23
to django-...@googlegroups.com
#7430: Recursively iterating through a template's nodes
-------------------------------------+-------------------------------------
Reporter: miracle2k | Owner: Anders
| Hovmöller
Type: Bug | Status: assigned
Component: Template system | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"69069a443a906dd4060a8047e683657d40b4c383" 69069a4]:
{{{
#!CommitTicketReference repository=""
revision="69069a443a906dd4060a8047e683657d40b4c383"
Refs #7430 -- Removed broken Template.__iter__().

Co-authored-by: Anders Hovmöller <anders.h...@dryft.se>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/7430#comment:11>

Django

unread,
Feb 8, 2023, 5:20:24 AM2/8/23
to django-...@googlegroups.com
#7430: Recursively iterating through a template's nodes
-------------------------------------+-------------------------------------
Reporter: miracle2k | Owner: Anders
| Hovmöller
Type: Bug | Status: closed

Component: Template system | Version: dev
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* status: assigned => closed
* resolution: => wontfix
* stage: Ready for checkin => Unreviewed


Comment:

As per Tim's suggestion on the PR, resolving this as `wontfix`, since
directly iterating a template's nodes isn't supported.
(Short of a rationale and proof-of-concept, it doesn't seem likely to be
added.)

--
Ticket URL: <https://code.djangoproject.com/ticket/7430#comment:12>

Reply all
Reply to author
Forward
0 new messages