Created
July 30, 2012 14:27
-
-
Save abele/3207346 to your computer and use it in GitHub Desktop.
Abstraction on request_local()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tw2/core/resources.py: 81 | |
# Before: | |
def prepare(self): | |
super(Resource, self).prepare() | |
rl = core.request_local() | |
rl_resources = rl.setdefault('resources', []) | |
rl_location = rl['middleware'].config.inject_resources_location | |
if self not in rl_resources: | |
if self.location is '__use_middleware': | |
self.location = rl_location | |
rl_resources.append(self) | |
# After: | |
def prepare(self): | |
super(Resource, self).prepare() | |
if self.location is '__use_middleware': | |
inject_location = core.configuration().inject_resources_location | |
self.location = inject_location | |
core.queue_resource(self) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment