-
Notifications
You must be signed in to change notification settings - Fork 149
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 request.current_service attribute #105
Labels
Comments
That is something I did a lot for this CORS work, and probably it could be useful in other cases. I'm also thinking about making the service available in the view as well (maybe in |
leplatrem
changed the title
Pass the service object into each validator by default
Add request.current_service attribute
Oct 20, 2016
def current_service(request):
"""Return the Cornice service matching the specified request.
:returns: the service or None if unmatched.
:rtype: cornice.Service
"""
if request.matched_route:
services = request.registry.cornice_services
pattern = request.matched_route.pattern
try:
service = services[pattern]
except KeyError:
return None
else:
return service
config.add_request_method(current_service, reify=True) |
leplatrem
added a commit
that referenced
this issue
Dec 14, 2016
leplatrem
added a commit
that referenced
this issue
Dec 15, 2016
Add a request.current_service attribute (fixes #105)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In #98, @rfk said:
The text was updated successfully, but these errors were encountered: