-
Notifications
You must be signed in to change notification settings - Fork 66
Description
Is your feature request related to a problem? Please describe.
In this gitter comment, @kaidokert noted that there aren't any ways to make objects available to decorators at runtime. Notably, we were trying to pass a cache provider supplied as a constructor argument at runtime to a custom cache decorator.
Describe the solution you'd like
What might be a neat idea to explore is adding a Context function annotation (i.e., ArgumentAnnotation subclass) that can be used to provide data to a MethodAnnotation. This way, you can annotate one of the constructor arguments with Context(key=cache.CACHE_PROVIDER), then the value of that argument becomes available to the @cache decorator by querying a dictionary of context objects exposed through the request_builder (e.g., request_builder.context[cache.CACHE_PROVIDER]). Then, in cache.modify_request, you can check the existence of the cache-manager key in the request's context and conditionally add the cache RequestTemplate to the request builder if that key exists.
Additional context
N/A