Opened 9 years ago

Closed 8 years ago

#2154 closed enhancement (fixed)

[patch] save_insert and save_update signals

Reported by: Matias Hermanrud Fjeld Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: minor Keywords: feature
Cc: mir@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

This patch adds two new signals: save_update and save_insert.
They are called from the Models.save()-method, when an update statement is executed,
or when an insert statement is executed, respectivly.

Attachments (2)

insert_update_signals.diff (1.5 KB) - added by Matias Hermanrud Fjeld <mhf@…> 9 years ago.
insert_update_signals2.diff (1.4 KB) - added by mhf@… 9 years ago.
Signals are sent after insert/update

Download all attachments as: .zip

Change History (7)

Changed 9 years ago by Matias Hermanrud Fjeld <mhf@…>

comment:1 Changed 9 years ago by mir@…

  • Cc mir@… added

Interesting ... I'm adding some auditlog to my app, and I'd rather in need of a post_insert, so that the primary key has been assigned when the signal is sent. What are you using this for?

comment:2 Changed 9 years ago by mhf@…

I have a dyndns app, and to have it update dns-entries when the hostname is changed, I need to distinguish between inserts and updates:

a host object is created -> do nothing.
a host object is changed -> update dns.

But I don't really need the signals before, so i've included a new patch that sends the signals after updates/inserts.
Maybe this should be four signals: {pre,post}_{update,insert}? It'll probably have to wait untill somebody asks for it.

Changed 9 years ago by mhf@…

Signals are sent after insert/update

comment:3 Changed 8 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Design decision needed

comment:4 Changed 8 years ago by PhiR

  • Keywords feature added

comment:5 Changed 8 years ago by jacob

  • Resolution set to fixed
  • Status changed from new to closed

There's currently a "created" flag on the post-save hook, so I'm marking this fixed.

Note: See TracTickets for help on using tickets.
Back to Top