django-bulk-hooks 0.1.82__py3-none-any.whl → 0.1.83__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.

@@ -57,32 +57,31 @@ class HookModelMixin(models.Model):
57
57
 
58
58
  def save(self, *args, **kwargs):
59
59
  is_create = self.pk is None
60
+ ctx = HookContext(self.__class__)
60
61
 
61
62
  if is_create:
62
- # For create operations, we don't have old records
63
- ctx = HookContext(self.__class__)
64
- run(self.__class__, BEFORE_CREATE, [self], ctx=ctx)
65
-
63
+ # For create operations, let Django save first so relationships are set up
66
64
  super().save(*args, **kwargs)
67
-
65
+
66
+ # Now run hooks after Django has set up the object
67
+ run(self.__class__, BEFORE_CREATE, [self], ctx=ctx)
68
68
  run(self.__class__, AFTER_CREATE, [self], ctx=ctx)
69
69
  else:
70
70
  # For update operations, we need to get the old record
71
71
  try:
72
72
  old_instance = self.__class__.objects.get(pk=self.pk)
73
- ctx = HookContext(self.__class__)
74
- run(self.__class__, BEFORE_UPDATE, [self], [old_instance], ctx=ctx)
75
-
73
+
74
+ # Let Django save first
76
75
  super().save(*args, **kwargs)
77
-
76
+
77
+ # Now run hooks after Django has set up the object
78
+ run(self.__class__, BEFORE_UPDATE, [self], [old_instance], ctx=ctx)
78
79
  run(self.__class__, AFTER_UPDATE, [self], [old_instance], ctx=ctx)
79
80
  except self.__class__.DoesNotExist:
80
81
  # If the old instance doesn't exist, treat as create
81
- ctx = HookContext(self.__class__)
82
- run(self.__class__, BEFORE_CREATE, [self], ctx=ctx)
83
-
84
82
  super().save(*args, **kwargs)
85
-
83
+
84
+ run(self.__class__, BEFORE_CREATE, [self], ctx=ctx)
86
85
  run(self.__class__, AFTER_CREATE, [self], ctx=ctx)
87
86
 
88
87
  return self
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: django-bulk-hooks
3
- Version: 0.1.82
3
+ Version: 0.1.83
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
@@ -7,10 +7,10 @@ django_bulk_hooks/engine.py,sha256=b1AO8qyl2VMt1CHyefn1Gt1_ARaV80yBZ3mGXsJ9_eA,2
7
7
  django_bulk_hooks/enums.py,sha256=Zo8_tJzuzZ2IKfVc7gZ-0tWPT8q1QhqZbAyoh9ZVJbs,381
8
8
  django_bulk_hooks/handler.py,sha256=Qpg_zT6SsQiTlhduvzXxPdG6uynjyR2fBjj-R6HZiXI,4861
9
9
  django_bulk_hooks/manager.py,sha256=-V128ACxPAz82ua4jQRFUkjAKtKW4MN5ppz0bHcv5s4,7138
10
- django_bulk_hooks/models.py,sha256=S4CLMcZeOv0XWCmmC7ieOExL73WmfWUKXPYD3N9wrVc,3666
10
+ django_bulk_hooks/models.py,sha256=m_dsCcKX8euGU-aDvlkY-vi5QTsRaXhyT-6EZotYuXM,3813
11
11
  django_bulk_hooks/queryset.py,sha256=7lLqhZ-XOYsZ1I3Loxi4Nhz79M8HlTYE413AW8nyeDI,1330
12
12
  django_bulk_hooks/registry.py,sha256=Vh78exKYcdZhM27120kQm-iXGOjd_kf9ZUYBZ8eQ2V0,683
13
- django_bulk_hooks-0.1.82.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
14
- django_bulk_hooks-0.1.82.dist-info/METADATA,sha256=gYgpti0VC1zlAh2NlINn-lyAPPCXkB0K1XzIq4WgsxM,9051
15
- django_bulk_hooks-0.1.82.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
16
- django_bulk_hooks-0.1.82.dist-info/RECORD,,
13
+ django_bulk_hooks-0.1.83.dist-info/LICENSE,sha256=dguKIcbDGeZD-vXWdLyErPUALYOvtX_fO4Zjhq481uk,1088
14
+ django_bulk_hooks-0.1.83.dist-info/METADATA,sha256=G6_6NsM-MqUem0Y5fmZz0pktXtmsaIVpglFeBDIv7JM,9051
15
+ django_bulk_hooks-0.1.83.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
16
+ django_bulk_hooks-0.1.83.dist-info/RECORD,,