Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#5422 closed (fixed)

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

Reported by: graham.carlyle@… Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Keywords:
Cc: huddlej@…, jonathan.buchanan@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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 (2)

save-send-raw-flag.diff (900 bytes ) - added by graham.carlyle@… 17 years ago.
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@… 17 years ago.
Updated patch against trunk and updated corresponding tests

Download all attachments as: .zip

Change History (8)

by graham.carlyle@…, 17 years ago

Attachment: save-send-raw-flag.diff added

Passes raw flag from save to pre_save & post_save signal handlers

comment:1 by graham.carlyle@…, 17 years ago

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

comment:2 by anonymous, 17 years ago

Cc: huddlej@… added

comment:3 by Bastian Kleineidam <calvin@…>, 17 years ago

The patch works fine on my development servers, thanks!

by graham.carlyle@…, 17 years ago

Attachment: save-send-raw-flag_v2.diff added

Updated patch against trunk and updated corresponding tests

comment:4 by Jonathan Buchanan, 17 years ago

Cc: jonathan.buchanan@… added

comment:5 by Gary Wilson, 17 years ago

Resolution: fixed
Status: newclosed

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

comment:6 by Gary Wilson, 17 years ago

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.

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