Opened 13 years ago

Closed 13 years ago

#4563 closed (fixed)

Context should expose removed/added scope objects (dicts)

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


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) 13 years ago.

Download all attachments as: .zip

Change History (4)

Changed 13 years ago by (removed)

Attachment: expand-context-api.patch added

comment:1 Changed 13 years ago by Chris Beaven

Triage Stage: UnreviewedDesign decision needed

+1 for me

comment:2 Changed 13 years ago by Jacob

Triage Stage: Design decision neededReady for checkin

comment:3 Changed 13 years ago by Malcolm Tredinnick

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