mirror of
https://github.com/jazzband/django-configurations.git
synced 2026-05-09 16:14:47 +00:00
This monkey-patching broke procrastinate in an interesting way:
Procrastinate uses the add_arguments hook to check the previously
defined arguments like this:
```python
class Command(BaseCommand):
def add_arguments(self, parser):
self._django_options = {a.dest for a in parser._actions}
...
```
in order to later filter them out like this:
```python
def handle(self, *args, **kwargs):
...
kwargs = {k: v for k, v in kwargs.items() if k not in self._django_options}
...
```
This is a problem because the CONFIGURATION_ARGUMENT arg is added
*after* procrastinate's `add_arguments` is called. Here's the call
graph:
```
create_parser (django-configurations)
-> create_parser (django) (a.k.a. orig_create_parser)
-> add_arguments (procrastinate)
-> (CONFIGURATION_ARGUMENT added here)
```
This commit esesentially swaps the inner two actions so it looks like
this:
```
create_parser (django-configurations)
-> create_parser (django) (a.k.a. orig_create_parser)
-> (CONFIGURATION_ARGUMENT added here)
-> add_arguments (procrastinate)
```
It does this by temporarily overriding `add_arguments` with a no-op and
then later restoring and calling it.
This is a hack on top of two hacks, but I can't really see any other
ways to make it work.
|
||
|---|---|---|
| .. | ||
| __init__.py | ||
| __main__.py | ||
| asgi.py | ||
| base.py | ||
| decorators.py | ||
| fastcgi.py | ||
| importer.py | ||
| management.py | ||
| sphinx.py | ||
| utils.py | ||
| values.py | ||
| version.py | ||
| wsgi.py | ||