Changes between Initial Version and Version 2 of Ticket #11134


Ignore:
Timestamp:
May 18, 2009, 11:24:32 PM (16 years ago)
Author:
Gary Wilson
Comment:

Honza, I've got a few questions about the use case you mentioned in IRC:

"The use case is that we have a FormField, that stores text in markup in external Model, and passes rendered text in its clean, then registers the post_save hook to save the markup somewhere to enable later editing."

You mention that, as shown in the attached tests, that the second receiver doesn't get run or removed and that this causes problems for the next instance that gets saved.

Well, don't you still have a problem if some other thread saves a different instance of the Model before save gets called on the target instance? In this case, the receivers would get called on the different instance, get removed from the post_save hook, then not get called when the target instance is saved. Or do you not care to be thread safe?

Also, what happens if this custom field cleans fine, but the form still had errors in other fields. In this case the receivers are still connected and could cause havoc on the next instance saved.

If all you are doing is registering receivers and then removing them, could you not simply call the receiver functions after you save the instance and not hook them up to the signal at all? For example, in a post_save method of the field that the form calls after successful validation.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #11134

    • Property Milestone1.1
    • Property Owner changed from nobody to Honza Král
  • Ticket #11134 – Description

    initial v2  
    1 This happens because {{{disconnect()}}} method does {{{del self.receivers[index]}}} while {{{self.receivers}}} are eing iterated over in {{{_live_receivers()}}}.
     1This happens because {{{disconnect()}}} method does {{{del self.receivers[index]}}} while {{{self.receivers}}} are being iterated over in {{{_live_receivers()}}}.
    22
    33The attached patch has tests and a fix, the tests fail for me without the fix, passes after the fix is applied.
Back to Top