I am building a some event driven logic and one of those is to create a Role Profile if it does not exists, so I added a method in hooks.py > User< before_insert but it was throwing an error saying that link does not exists.
After seeing the logic turns out the code validates links before running hooks.
Would that be possible to move after certain hook? I know I can pass ignore_links, but I do not want to do that, since I want ot make sure that it validates the links. Running doc._validate_links() defeats the purpose.
# code
self._validate_links() # Error in thrown here
self.check_permission("create")
self.run_method("before_insert")
# code happens here
self.run_before_save_methods() # `before_validate` is triggered here
self._validate()
Do one thing: pass ignore_links as an argument and manually call self._validate_links() afterward. Then it will validate the links.
and use database transactions; if anything fails, the transaction will be rolled back.