django-bulk-hooks 0.1.187__py3-none-any.whl → 0.1.189__py3-none-any.whl

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.

@@ -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
- queryset = HookQuerySet(self.model, using=self._db)
9
- return queryset
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,