papyrus icon indicating copy to clipboard operation
papyrus copied to clipboard

Add after create callback

Open sbrunner opened this issue 1 year ago • 3 comments

sbrunner avatar Sep 06 '24 13:09 sbrunner

Existing before_create is passed obj=None, so docstring is a bit messy ("..., and the database object to be updated").

The object is not always None, an object is passed if we send an ID!

sbrunner avatar Sep 06 '24 15:09 sbrunner

Updated :-)

sbrunner avatar Sep 06 '24 15:09 sbrunner

The object is not always None, an object is passed if we send an ID!

Ok so this is not a create nor insert, it is an update

We could discuss about what to do in such case, but it not the subject of this PR.

Should we call before_update in such case ?

arnaud-morvan avatar Sep 06 '24 16:09 arnaud-morvan

before_update already exists for object update :-) before_insert with the code you propose (I modified it a little bit by removing the unneeded create variable), it looks correct :-)

sbrunner avatar Sep 09 '24 06:09 sbrunner