You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just wondering whether Hooks can be emplemented externally in any part of the app. Something like Django signals. So that wherever a record changes or is added in the database, even if the action was called from the admin panel, the Hook would still be triggered . I think this restriction to PiccoloCrud alone is very limiting. I wish there could be a Django-like approach to this.
Thanks a lot. I observed that the run method is called when adding records. But doesn't seem to be called when updating existing records.
Quite complicated, just like you said.
@Fidel-C You can also try something like this. It is based on the @dantownsend code with minor modifications to use (override) also save (both save and update) and remove methods.
Activity
dantownsend commentedon Aug 22, 2024
There isn't an official way of doing it at the moment - it's possible to override the save method on a table, but a bit tricky.
Having a proper API for it would be nice, as it's a much more common requirement than I expected.
Fidel-C commentedon Aug 22, 2024
Looking forward to that then.
Fidel-C commentedon Sep 26, 2024
A code example showing how to override the save method on a table will be good. I can't see how to that.
dantownsend commentedon Sep 26, 2024
It's something like this:
The reason it looks a bit complicated is because Piccolo lets you run a query as sync or async.
Fidel-C commentedon Sep 27, 2024
Thanks a lot. I observed that the run method is called when adding records. But doesn't seem to be called when updating existing records.
Quite complicated, just like you said.
sinisaos commentedon Sep 27, 2024
@Fidel-C You can also try something like this. It is based on the @dantownsend code with minor modifications to use (override) also
save(bothsaveandupdate) andremovemethods.Fidel-C commentedon Sep 28, 2024
@sinisaos Thanks a lot.