Opened 17 years ago

Closed 17 years ago

#4563 closed (fixed)

Context should expose removed/added scope objects (dicts)

Reported by: (removed) Owned by: nobody
Component: Template system Version: dev
Severity: Keywords:
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

Originally suggested it in the 'ForNode multiple args' thread, but opening a ticket for it now since it's generally useful.

Basically, proposing that Context.(push|update) return the newly added scope, and that Context.pop() returns the removed scope (for reasons of API symmetry mainly). The main reasoning behind this is that it's useful to bypass Context when doing more then setting a key or two- Context's api isn't as full featured as dicts (nor necessarily should it be).

Right now, can do similar tricks via passing in the new scope to update, but that's not particularly friendly/obvious- alternative being reaching into the Context internal stack, which again, isn't very friendly (screws encapsulation anyways). Bypassing context for doing scope updates is actually fairly useful- very least, access to .clear() is a nice way to avoid continual pop/push on the stack per iteration.

Attachments (1)

expand-context-api.patch (945 bytes ) - added by (removed) 17 years ago.

Download all attachments as: .zip

Change History (4)

by (removed), 17 years ago

Attachment: expand-context-api.patch added

comment:1 by Chris Beaven, 17 years ago

Triage Stage: UnreviewedDesign decision needed

+1 for me

comment:2 by Jacob, 17 years ago

Triage Stage: Design decision neededReady for checkin

comment:3 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

(In [6854]) Fixed #4563 -- Context.pop/push/update return the top-level dictionary (the new
one for push() and update(), the one removed for pop()). Based on a patch from
Brian Harring.

Note: See TracTickets for help on using tickets.
Back to Top