Opened 18 years ago
Closed 15 years ago
#4552 closed (fixed)
Tidy up "for" tag
| Reported by: | Chris Beaven | Owned by: | nobody |
|---|---|---|---|
| Component: | Template system | Version: | dev |
| Severity: | Keywords: | for loop | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Just a follow-up patch related to #3523 (Extend "for" tag to allow unpacking of lists) and it's recent checkin.
Currently there is a small difference between the single behaviour and the unpacking behaviour: for unpacking, the context scope is popped every loop iteration. This patch changes this behaviour to use the same scope throughout the loop's lifespan (making it behave more like the older single behaviour).
The patch also tidies up the comma-splitting through the use of re.split.
Attachments (2)
Change History (9)
by , 18 years ago
| Attachment: | for_tag_tidy.patch added |
|---|
comment:1 by , 18 years ago
| Triage Stage: | Unreviewed → Design decision needed |
|---|
comment:2 by , 18 years ago
comment:3 by , 16 years ago
| Needs tests: | set |
|---|
Going back through some of my old tickets.
If anything, I'd say this would be a speed increase. Currently, we're pushing and popping the context like crazy for unpacked fors. The second for is a safety method which is mostly a noop (except for a len() call) for most normal usage.
Apart from that, it is also a subtle change in behaviour (new items placed on the context are local to each iteration unpacked fors).
comment:4 by , 15 years ago
| Needs tests: | unset |
|---|---|
| Patch needs improvement: | set |
| Triage Stage: | Design decision needed → Accepted |
This is much less important now we have a RenderContext which should be used if you really care about context. Due to the age of the ticket, switching back to the original behavior would potentially cause more side-effects in third party projects than leaving it as-is.
The ticket is being left open because as jacob says the split change is good. So the "improved" patch just needs to do that.
by , 15 years ago
| Attachment: | for_tag_re_split.patch added |
|---|
comment:5 by , 15 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
comment:6 by , 15 years ago
| Patch needs improvement: | unset |
|---|
comment:7 by , 15 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Hrm... this is a tricky one. The re.split change is obviously good, but the other one looks like it'll be a bit slower, which I don't like.