biocore / biocore/microsetta-private-api
Explore if `validate_access` can be expressed as a decorator
- Dominant language
- Python
- Stars
- 6
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
This is potentially possible with the following type of pattern, where `new_f` performs a validation and only executes `f` if validation succeeds.
```python
In [20]: def bar(f):
...: def new_f(a, b):
...: if a > 5:
...: print("valid")
...: return f(a+5, b+5)
...: else:
...: print("invalid")
...: return None # or some failure function or whatever
...: return new_f
...:
In [21]: @bar
...: def foo(a, b):
...: print(a, b)
...:
In [22]: foo(3, 10)
invalid
In [23]: foo(6, 10)
valid
11 15
```
However, connexion injects other decorators so it is possible this will not work hence an exploration first.
Contributor guide
No contributing guide indexed for this repository
Research direction
No file or test is named. Start by locating the current validate_access implementation and tracing how Connexion applies its decorators and passes arguments. Done means establishing whether the decorator approach is compatible and documenting the resulting implementation scope or constraints.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, authorization, backend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100