Code

Opened 7 years ago

Closed 7 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: UI/UX:

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

Download all attachments as: .zip

Change History (4)

Changed 7 years ago by (removed)

comment:1 Changed 7 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

+1 for me

comment:2 Changed 7 years ago by jacob

  • Triage Stage changed from Design decision needed to Ready for checkin

comment:3 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.