django-bulk-hooks 0.1.190__tar.gz → 0.1.191__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.190 → django_bulk_hooks-0.1.191}/PKG-INFO +1 -1
- {django_bulk_hooks-0.1.190 → django_bulk_hooks-0.1.191}/django_bulk_hooks/manager.py +12 -43
- {django_bulk_hooks-0.1.190 → django_bulk_hooks-0.1.191}/pyproject.toml +1 -1
- {django_bulk_hooks-0.1.190 → django_bulk_hooks-0.1.191}/LICENSE +0 -0
- {django_bulk_hooks-0.1.190 → django_bulk_hooks-0.1.191}/README.md +0 -0
- {django_bulk_hooks-0.1.190 → django_bulk_hooks-0.1.191}/django_bulk_hooks/__init__.py +0 -0
- {django_bulk_hooks-0.1.190 → django_bulk_hooks-0.1.191}/django_bulk_hooks/conditions.py +0 -0
- {django_bulk_hooks-0.1.190 → django_bulk_hooks-0.1.191}/django_bulk_hooks/constants.py +0 -0
- {django_bulk_hooks-0.1.190 → django_bulk_hooks-0.1.191}/django_bulk_hooks/context.py +0 -0
- {django_bulk_hooks-0.1.190 → django_bulk_hooks-0.1.191}/django_bulk_hooks/decorators.py +0 -0
- {django_bulk_hooks-0.1.190 → django_bulk_hooks-0.1.191}/django_bulk_hooks/engine.py +0 -0
- {django_bulk_hooks-0.1.190 → django_bulk_hooks-0.1.191}/django_bulk_hooks/enums.py +0 -0
- {django_bulk_hooks-0.1.190 → django_bulk_hooks-0.1.191}/django_bulk_hooks/handler.py +0 -0
- {django_bulk_hooks-0.1.190 → django_bulk_hooks-0.1.191}/django_bulk_hooks/models.py +0 -0
- {django_bulk_hooks-0.1.190 → django_bulk_hooks-0.1.191}/django_bulk_hooks/priority.py +0 -0
- {django_bulk_hooks-0.1.190 → django_bulk_hooks-0.1.191}/django_bulk_hooks/queryset.py +0 -0
- {django_bulk_hooks-0.1.190 → django_bulk_hooks-0.1.191}/django_bulk_hooks/registry.py +0 -0
|
@@ -3,55 +3,24 @@ from django.db import models
|
|
|
3
3
|
from django_bulk_hooks.queryset import HookQuerySet, HookQuerySetMixin
|
|
4
4
|
|
|
5
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
|
-
A new queryset instance with bulk hook functionality added
|
|
16
|
-
"""
|
|
17
|
-
if isinstance(queryset, HookQuerySetMixin):
|
|
18
|
-
# Already has hook functionality, return as-is
|
|
19
|
-
return queryset
|
|
20
|
-
|
|
21
|
-
# Create a new class that inherits from both HookQuerySetMixin and the queryset's class
|
|
22
|
-
HookedQuerySetClass = type(
|
|
23
|
-
"HookedQuerySet",
|
|
24
|
-
(HookQuerySetMixin, queryset.__class__),
|
|
25
|
-
{
|
|
26
|
-
'__module__': 'django_bulk_hooks.queryset',
|
|
27
|
-
'__doc__': f'Dynamically created queryset with bulk hook functionality for {queryset.__class__.__name__}'
|
|
28
|
-
}
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
# Create a new instance with the same parameters
|
|
32
|
-
new_queryset = HookedQuerySetClass(
|
|
33
|
-
model=queryset.model,
|
|
34
|
-
query=queryset.query,
|
|
35
|
-
using=queryset._db,
|
|
36
|
-
hints=queryset._hints
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
# Copy any additional attributes that might be important
|
|
40
|
-
for attr, value in queryset.__dict__.items():
|
|
41
|
-
if not hasattr(new_queryset, attr):
|
|
42
|
-
setattr(new_queryset, attr, value)
|
|
43
|
-
|
|
44
|
-
return new_queryset
|
|
45
|
-
|
|
46
|
-
|
|
47
6
|
class BulkHookManager(models.Manager):
|
|
48
7
|
def get_queryset(self):
|
|
49
8
|
# Use super().get_queryset() to let Django and MRO build the queryset
|
|
50
9
|
# This ensures cooperation with other managers
|
|
51
10
|
base_queryset = super().get_queryset()
|
|
52
11
|
|
|
53
|
-
#
|
|
54
|
-
|
|
12
|
+
# If the base queryset already has hook functionality, return it as-is
|
|
13
|
+
if isinstance(base_queryset, HookQuerySetMixin):
|
|
14
|
+
return base_queryset
|
|
15
|
+
|
|
16
|
+
# Otherwise, create a new HookQuerySet with the same parameters
|
|
17
|
+
# This is much simpler and avoids dynamic class creation issues
|
|
18
|
+
return HookQuerySet(
|
|
19
|
+
model=base_queryset.model,
|
|
20
|
+
query=base_queryset.query,
|
|
21
|
+
using=base_queryset._db,
|
|
22
|
+
hints=base_queryset._hints
|
|
23
|
+
)
|
|
55
24
|
|
|
56
25
|
def bulk_create(
|
|
57
26
|
self,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "django-bulk-hooks"
|
|
3
|
-
version = "0.1.
|
|
3
|
+
version = "0.1.191"
|
|
4
4
|
description = "Hook-style hooks for Django bulk operations like bulk_create and bulk_update."
|
|
5
5
|
authors = ["Konrad Beck <konrad.beck@merchantcapital.co.za>"]
|
|
6
6
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|