django-bulk-hooks 0.1.187__tar.gz → 0.1.189__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of django-bulk-hooks might be problematic. Click here for more details.
- {django_bulk_hooks-0.1.187 → django_bulk_hooks-0.1.189}/PKG-INFO +8 -3
- {django_bulk_hooks-0.1.187 → django_bulk_hooks-0.1.189}/README.md +7 -2
- {django_bulk_hooks-0.1.187 → django_bulk_hooks-0.1.189}/django_bulk_hooks/manager.py +30 -3
- {django_bulk_hooks-0.1.187 → django_bulk_hooks-0.1.189}/django_bulk_hooks/queryset.py +742 -705
- {django_bulk_hooks-0.1.187 → django_bulk_hooks-0.1.189}/pyproject.toml +1 -1
- {django_bulk_hooks-0.1.187 → django_bulk_hooks-0.1.189}/LICENSE +0 -0
- {django_bulk_hooks-0.1.187 → django_bulk_hooks-0.1.189}/django_bulk_hooks/__init__.py +0 -0
- {django_bulk_hooks-0.1.187 → django_bulk_hooks-0.1.189}/django_bulk_hooks/conditions.py +0 -0
- {django_bulk_hooks-0.1.187 → django_bulk_hooks-0.1.189}/django_bulk_hooks/constants.py +0 -0
- {django_bulk_hooks-0.1.187 → django_bulk_hooks-0.1.189}/django_bulk_hooks/context.py +0 -0
- {django_bulk_hooks-0.1.187 → django_bulk_hooks-0.1.189}/django_bulk_hooks/decorators.py +0 -0
- {django_bulk_hooks-0.1.187 → django_bulk_hooks-0.1.189}/django_bulk_hooks/engine.py +0 -0
- {django_bulk_hooks-0.1.187 → django_bulk_hooks-0.1.189}/django_bulk_hooks/enums.py +0 -0
- {django_bulk_hooks-0.1.187 → django_bulk_hooks-0.1.189}/django_bulk_hooks/handler.py +0 -0
- {django_bulk_hooks-0.1.187 → django_bulk_hooks-0.1.189}/django_bulk_hooks/models.py +0 -0
- {django_bulk_hooks-0.1.187 → django_bulk_hooks-0.1.189}/django_bulk_hooks/priority.py +0 -0
- {django_bulk_hooks-0.1.187 → django_bulk_hooks-0.1.189}/django_bulk_hooks/registry.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: django-bulk-hooks
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.189
|
|
4
4
|
Summary: Hook-style hooks for Django bulk operations like bulk_create and bulk_update.
|
|
5
5
|
License: MIT
|
|
6
6
|
Keywords: django,bulk,hooks
|
|
@@ -202,15 +202,20 @@ reordered = [account3, account1, account2] # IDs: 3, 1, 2
|
|
|
202
202
|
LoanAccount.objects.bulk_update(reordered, ['balance'])
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
-
## 🧩 Integration with
|
|
205
|
+
## 🧩 Integration with Other Managers
|
|
206
206
|
|
|
207
|
-
You can extend from `BulkHookManager` to
|
|
207
|
+
You can extend from `BulkHookManager` to work with other manager classes. The manager uses a cooperative approach that dynamically injects bulk hook functionality into any queryset, ensuring compatibility with other managers.
|
|
208
208
|
|
|
209
209
|
```python
|
|
210
|
+
from django_bulk_hooks.manager import BulkHookManager
|
|
211
|
+
from queryable_properties.managers import QueryablePropertiesManager
|
|
212
|
+
|
|
210
213
|
class MyManager(BulkHookManager, QueryablePropertiesManager):
|
|
211
214
|
pass
|
|
212
215
|
```
|
|
213
216
|
|
|
217
|
+
This approach uses the industry-standard injection pattern, similar to how `QueryablePropertiesManager` works, ensuring both functionalities work seamlessly together without any framework-specific knowledge.
|
|
218
|
+
|
|
214
219
|
## 📝 License
|
|
215
220
|
|
|
216
221
|
MIT © 2024 Augend / Konrad Beck
|
|
@@ -183,15 +183,20 @@ reordered = [account3, account1, account2] # IDs: 3, 1, 2
|
|
|
183
183
|
LoanAccount.objects.bulk_update(reordered, ['balance'])
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
## 🧩 Integration with
|
|
186
|
+
## 🧩 Integration with Other Managers
|
|
187
187
|
|
|
188
|
-
You can extend from `BulkHookManager` to
|
|
188
|
+
You can extend from `BulkHookManager` to work with other manager classes. The manager uses a cooperative approach that dynamically injects bulk hook functionality into any queryset, ensuring compatibility with other managers.
|
|
189
189
|
|
|
190
190
|
```python
|
|
191
|
+
from django_bulk_hooks.manager import BulkHookManager
|
|
192
|
+
from queryable_properties.managers import QueryablePropertiesManager
|
|
193
|
+
|
|
191
194
|
class MyManager(BulkHookManager, QueryablePropertiesManager):
|
|
192
195
|
pass
|
|
193
196
|
```
|
|
194
197
|
|
|
198
|
+
This approach uses the industry-standard injection pattern, similar to how `QueryablePropertiesManager` works, ensuring both functionalities work seamlessly together without any framework-specific knowledge.
|
|
199
|
+
|
|
195
200
|
## 📝 License
|
|
196
201
|
|
|
197
202
|
MIT © 2024 Augend / Konrad Beck
|
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
from django.db import models
|
|
2
2
|
|
|
3
|
-
from django_bulk_hooks.queryset import HookQuerySet
|
|
3
|
+
from django_bulk_hooks.queryset import HookQuerySet, HookQuerySetMixin
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def inject_bulk_hook_behavior(queryset):
|
|
7
|
+
"""
|
|
8
|
+
Dynamically inject bulk hook behavior into any queryset.
|
|
9
|
+
This follows the industry-standard pattern for cooperative queryset extensions.
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
queryset: Any Django QuerySet instance
|
|
13
|
+
|
|
14
|
+
Returns:
|
|
15
|
+
The same queryset instance with bulk hook functionality added
|
|
16
|
+
"""
|
|
17
|
+
if not isinstance(queryset, HookQuerySetMixin):
|
|
18
|
+
# Create a new class that inherits from both HookQuerySetMixin and the queryset's class
|
|
19
|
+
HookedQuerySetClass = type(
|
|
20
|
+
"HookedQuerySet",
|
|
21
|
+
(HookQuerySetMixin, queryset.__class__),
|
|
22
|
+
{}
|
|
23
|
+
)
|
|
24
|
+
# Change the instance's class to the new hybrid class
|
|
25
|
+
queryset.__class__ = HookedQuerySetClass
|
|
26
|
+
return queryset
|
|
4
27
|
|
|
5
28
|
|
|
6
29
|
class BulkHookManager(models.Manager):
|
|
7
30
|
def get_queryset(self):
|
|
8
|
-
|
|
9
|
-
|
|
31
|
+
# Use super().get_queryset() to let Django and MRO build the queryset
|
|
32
|
+
# This ensures cooperation with other managers
|
|
33
|
+
base_queryset = super().get_queryset()
|
|
34
|
+
|
|
35
|
+
# Inject our bulk hook behavior into the queryset
|
|
36
|
+
return inject_bulk_hook_behavior(base_queryset)
|
|
10
37
|
|
|
11
38
|
def bulk_create(
|
|
12
39
|
self,
|