Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pop and setdefault to AppCtxGlobals #1509

Merged
merged 1 commit into from
Jun 30, 2015

Conversation

ThiefMaster
Copy link
Member

While easy to implement with a custom app_ctx_globals_class class, I believe these two methods are useful enough to add them to the default class.

Especially setdefault makes lots of sense if you e.g. cache something on the app context globals and thus want to do something like this:

cache = g.setdefault('whatever_cache', {})
try:
    return cache['foo']
except KeyError:
    rv = cache['foo'] = get_foo()
    return rv

@untitaker
Copy link
Contributor

Right, thanks!

untitaker added a commit that referenced this pull request Jun 30, 2015
Add pop and setdefault to AppCtxGlobals
@untitaker untitaker merged commit 3747487 into pallets:master Jun 30, 2015
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants