django-bulk-hooks 0.1.219__py3-none-any.whl → 0.1.220__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.
- django_bulk_hooks/conditions.py +9 -4
- django_bulk_hooks/models.py +6 -7
- django_bulk_hooks/registry.py +3 -0
- {django_bulk_hooks-0.1.219.dist-info → django_bulk_hooks-0.1.220.dist-info}/METADATA +1 -1
- {django_bulk_hooks-0.1.219.dist-info → django_bulk_hooks-0.1.220.dist-info}/RECORD +7 -7
- {django_bulk_hooks-0.1.219.dist-info → django_bulk_hooks-0.1.220.dist-info}/LICENSE +0 -0
- {django_bulk_hooks-0.1.219.dist-info → django_bulk_hooks-0.1.220.dist-info}/WHEEL +0 -0
django_bulk_hooks/conditions.py
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
logger = logging.getLogger(__name__)
|
|
4
|
+
|
|
5
|
+
|
|
1
6
|
def resolve_dotted_attr(instance, dotted_path):
|
|
2
7
|
"""
|
|
3
8
|
Recursively resolve a dotted attribute path, e.g., "type.category".
|
|
@@ -66,11 +71,11 @@ class HasChanged(HookCondition):
|
|
|
66
71
|
self.has_changed = has_changed
|
|
67
72
|
|
|
68
73
|
def check(self, instance, original_instance=None):
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
logger.debug(f"HasChanged.check called for field '{self.field}' on instance {getattr(instance, 'pk', 'No PK')}")
|
|
75
|
+
logger.debug(f"Original instance: {getattr(original_instance, 'pk', 'No PK') if original_instance else 'None'}")
|
|
71
76
|
|
|
72
77
|
if not original_instance:
|
|
73
|
-
|
|
78
|
+
logger.debug("No original instance, returning False")
|
|
74
79
|
return False
|
|
75
80
|
|
|
76
81
|
current = resolve_dotted_attr(instance, self.field)
|
|
@@ -78,7 +83,7 @@ class HasChanged(HookCondition):
|
|
|
78
83
|
|
|
79
84
|
# Add more detailed debugging
|
|
80
85
|
result = (current != previous) == self.has_changed
|
|
81
|
-
|
|
86
|
+
logger.debug(f"HasChanged {self.field} result={result}")
|
|
82
87
|
return result
|
|
83
88
|
|
|
84
89
|
|
django_bulk_hooks/models.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import logging
|
|
1
2
|
from django.db import models
|
|
2
3
|
|
|
3
4
|
from django_bulk_hooks.constants import (
|
|
@@ -15,6 +16,8 @@ from django_bulk_hooks.context import HookContext
|
|
|
15
16
|
from django_bulk_hooks.engine import run
|
|
16
17
|
from django_bulk_hooks.manager import BulkHookManager
|
|
17
18
|
|
|
19
|
+
logger = logging.getLogger(__name__)
|
|
20
|
+
|
|
18
21
|
|
|
19
22
|
class HookModelMixin(models.Model):
|
|
20
23
|
objects = BulkHookManager()
|
|
@@ -56,15 +59,13 @@ class HookModelMixin(models.Model):
|
|
|
56
59
|
def save(self, *args, bypass_hooks=False, **kwargs):
|
|
57
60
|
# If bypass_hooks is True, use base manager to avoid triggering hooks
|
|
58
61
|
if bypass_hooks:
|
|
59
|
-
|
|
60
|
-
f"DEBUG: save() called with bypass_hooks=True for {self.__class__.__name__} pk={self.pk}"
|
|
61
|
-
)
|
|
62
|
+
logger.debug(f"save() called with bypass_hooks=True for {self.__class__.__name__} pk={self.pk}")
|
|
62
63
|
return self._base_manager.save(self, *args, **kwargs)
|
|
63
64
|
|
|
64
65
|
is_create = self.pk is None
|
|
65
66
|
|
|
66
67
|
if is_create:
|
|
67
|
-
|
|
68
|
+
logger.debug(f"save() creating new {self.__class__.__name__} instance")
|
|
68
69
|
# For create operations, we don't have old records
|
|
69
70
|
ctx = HookContext(self.__class__)
|
|
70
71
|
run(self.__class__, BEFORE_CREATE, [self], ctx=ctx)
|
|
@@ -73,9 +74,7 @@ class HookModelMixin(models.Model):
|
|
|
73
74
|
|
|
74
75
|
run(self.__class__, AFTER_CREATE, [self], ctx=ctx)
|
|
75
76
|
else:
|
|
76
|
-
|
|
77
|
-
f"DEBUG: save() updating existing {self.__class__.__name__} instance pk={self.pk}"
|
|
78
|
-
)
|
|
77
|
+
logger.debug(f"save() updating existing {self.__class__.__name__} instance pk={self.pk}")
|
|
79
78
|
# For update operations, we need to get the old record
|
|
80
79
|
try:
|
|
81
80
|
# Use _base_manager to avoid triggering hooks recursively
|
django_bulk_hooks/registry.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
django_bulk_hooks/__init__.py,sha256=uUgpnb9AWjIAcWNpCMqBcOewSnpJjJYH6cjPbQkzoNU,140
|
|
2
|
-
django_bulk_hooks/conditions.py,sha256=
|
|
2
|
+
django_bulk_hooks/conditions.py,sha256=hI-LfcRZBiBrmfAVJZfjEnw7F2XJ0xvkd4J3NGzMpGc,6572
|
|
3
3
|
django_bulk_hooks/constants.py,sha256=3x1H1fSUUNo0DZONN7GUVDuySZctTR-jtByBHmAIX5w,303
|
|
4
4
|
django_bulk_hooks/context.py,sha256=_NbGWTq9s66g0vbFIaqN4GlIHWQmFg3EQ44qY8YvvEg,1537
|
|
5
5
|
django_bulk_hooks/decorators.py,sha256=WD7Jn7QAvY8F4wOsYlIpjoM9-FdHXSKB7hH9ot-lkYQ,4896
|
|
@@ -7,11 +7,11 @@ django_bulk_hooks/engine.py,sha256=t_kvgex6_iZEFc5LK-srBTZPe-1bdlYdip5LfWOc6lc,2
|
|
|
7
7
|
django_bulk_hooks/enums.py,sha256=Zo8_tJzuzZ2IKfVc7gZ-0tWPT8q1QhqZbAyoh9ZVJbs,381
|
|
8
8
|
django_bulk_hooks/handler.py,sha256=xZt8iNdYF-ACz-MnKMY0co6scWINU5V5wC1lyDn844k,4854
|
|
9
9
|
django_bulk_hooks/manager.py,sha256=nfWiwU5-yAoxdnQsUMohxtyCpkV0MBv6X3wmipr9eQY,3697
|
|
10
|
-
django_bulk_hooks/models.py,sha256=
|
|
10
|
+
django_bulk_hooks/models.py,sha256=exnXYVKEVbYAXhChCP8VdWTnKCnm9DiTcokEIBee1I0,4350
|
|
11
11
|
django_bulk_hooks/priority.py,sha256=HG_2D35nga68lBCZmSXTcplXrjFoRgZFRDOy4ROKonY,376
|
|
12
12
|
django_bulk_hooks/queryset.py,sha256=H9toczyQ4KZUGSi-M594vF3BRaSVQX-tqKb6GHe7ua0,32648
|
|
13
|
-
django_bulk_hooks/registry.py,sha256=
|
|
14
|
-
django_bulk_hooks-0.1.
|
|
15
|
-
django_bulk_hooks-0.1.
|
|
16
|
-
django_bulk_hooks-0.1.
|
|
17
|
-
django_bulk_hooks-0.1.
|
|
13
|
+
django_bulk_hooks/registry.py,sha256=T8ET5VGgvcRKhf5fuFXE8pNzWfkiIWN1QEGT-HyIS_E,957
|
|
14
|
+
django_bulk_hooks-0.1.220.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
|
|
15
|
+
django_bulk_hooks-0.1.220.dist-info/METADATA,sha256=zCKNbtprnajlqueQU707WJtzREhFTmKzScxioyab0-U,9061
|
|
16
|
+
django_bulk_hooks-0.1.220.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
17
|
+
django_bulk_hooks-0.1.220.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|