Django

Code

Ticket #5422 (closed: fixed)

Opened 10 months ago

Last modified 5 months ago

Passing raw flag as an additional parameter to post_save & pre_save signals

Reported by: graham.carlyle@maplecroft.net Assigned to: nobody
Milestone: Component: Database wrapper
Version: SVN Keywords:
Cc: huddlej@wwu.edu, jonathan.buchanan@gmail.com Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Signal handlers attached to pre_save & post_save signals are called when data is loaded from a fixture. If these signal handlers attempt to query/modify other records in the database then they may have problems as the database might not yet be in a consistent state if the fixture hasn't completed loading.

Work resulting from ticket #4495 avoided the calling of a custom save method when loading fixtures to avoid this same problem.

By passing the raw flag as an additional parameter to the signal handlers their implementations could decide whether to do any work and so avoid data consistency problems when the raw flag is True.

This change is unlikely to cause problems with existing signal handlers as named arguments are only passed to handlers that have those as parameters.

Attachments

save-send-raw-flag.diff (0.9 kB) - added by graham.carlyle@maplecroft.net on 09/13/07 11:09:04.
Passes raw flag from save to pre_save & post_save signal handlers
save-send-raw-flag_v2.diff (1.8 kB) - added by graham.carlyle@maplecroft.net on 11/12/07 10:34:26.
Updated patch against trunk and updated corresponding tests

Change History

09/13/07 11:09:04 changed by graham.carlyle@maplecroft.net

  • attachment save-send-raw-flag.diff added.

Passes raw flag from save to pre_save & post_save signal handlers

09/13/07 11:18:43 changed by graham.carlyle@maplecroft.net

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

Oops I meant "work resulting from ticket #4459..."

09/26/07 15:30:48 changed by anonymous

  • cc set to huddlej@wwu.edu.

10/10/07 03:14:32 changed by Bastian Kleineidam <calvin@debian.org>

The patch works fine on my development servers, thanks!

11/12/07 10:34:26 changed by graham.carlyle@maplecroft.net

  • attachment save-send-raw-flag_v2.diff added.

Updated patch against trunk and updated corresponding tests

12/31/07 19:22:34 changed by insin

  • cc changed from huddlej@wwu.edu to huddlej@wwu.edu, jonathan.buchanan@gmail.com.

02/01/08 11:32:30 changed by gwilson

  • status changed from new to closed.
  • resolution set to fixed.

(In [7054]) Fixed #5422 -- Added a raw parameter to model pre_save and post_save signals, based on patch from graham.carlyle@maplecroft.net.

02/01/08 11:33:11 changed by gwilson

Noting that this change is backwards-compatible since django.dispatch.robustapply.robustApply checks to see what arguments and keyword arguments the receiver accepts and only calls the receiver with those arguments.


Add/Change #5422 (Passing raw flag as an additional parameter to post_save & pre_save signals)




Change Properties
Action