twisted / twisted/klein

Not possible for injectors to reuse injected instances.

Open
#269 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Python
Stars
838
Forks
123
Avg merge
7h 58m
Merged PRs (30d)
12

Description

Given an IDependencyInjector for a type A and an IDependencyInjector for a type B which depends on an instance of A and a route that takes both injected parameters it's not currently possible for B's IDependencyInjector.injectValue to get the same instance of A that was injected directly into the route.

This is because although the router that invokes dependency injection records the injected value it does so into a copy of routeParams and does not subsequently invoke injectValue with the modified copy of routeParams.

https://github.com/twisted/klein/blob/b7dffcf84ccb86a79ec3e6cdf272c784289af96a/src/klein/_requirer.py#L205-L208

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/klein/_requirer.py at lines 205-208 and trace how the router records injected values in routeParams before invoking injectValue. Ensure a dependent injector can receive the same A instance already injected directly into the route; done means B's injector reuses that instance rather than receiving a separate one.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.