So here is my use case, simplified:
class Entry(models.Model):
document = models.BinaryField(blank=True, null=True)
document_received_ts = models.DateTimeField(null=True)
@hook(AFTER_UPDATE, when='document', was=None, has_changed=True, on_commit=True)
def has_received_document(self):
logger.info("%s received document", self)
self.document_received_ts = datetime.now()
self.save()
# … somewhere else …
some_entry.document = b'whatevs'
some_entry.save()
This used to work fine, however since 1.0.1 it runs into a RecursionError: maximum recursion depth exceeded while calling a Python object, calling the above hook over and over again, obviously triggered by the save(). I'm not sure why the above hook is triggered again, since it's an AFTER_UPDATE(on_commit=True), ie. the change has been persisted to the database. It should pick up that document has not changed from None again! However, it obviously does not and recurses until the stack runs out.
I can not just do a save(skip_hooks=True) because there might be other hooks that depend on this one…
My uneducated guess is that django-lifecycle needs to sync its change tracking info before running on_commit hooks?
So here is my use case, simplified:
This used to work fine, however since 1.0.1 it runs into a
RecursionError: maximum recursion depth exceeded while calling a Python object, calling the above hook over and over again, obviously triggered by thesave(). I'm not sure why the above hook is triggered again, since it's anAFTER_UPDATE(on_commit=True), ie. the change has been persisted to the database. It should pick up that document has not changed from None again! However, it obviously does not and recurses until the stack runs out.I can not just do a
save(skip_hooks=True)because there might be other hooks that depend on this one…My uneducated guess is that django-lifecycle needs to sync its change tracking info before running
on_commithooks?