openhatch / oh-mainline

The code that runs openhatch.org
http://openhatch.org
GNU Affero General Public License v3.0
242 stars 310 forks source link

Audit hooks in mysite/profile/models.py #1032

Open imported-from-roundup opened 10 years ago

imported-from-roundup commented 10 years ago

Comment by walkerh:

For both models.signals.post_save and models.signals.pre_save, you are supposed to check for a keyword argument of "raw" and suppress any modifications to other tables if raw is True.

See:


Comment by paulproteus:

I just realized -- this "raw" attribute is not present in Django 1.3.3, which is what we are using.

It shows up in Django 1.4.

I guess we should upgrade to Django 1.4.


Status: chatting Nosy List: paulproteus, walkerh Priority: feature Imported from roundup ID: 717 (view archived page) Last modified: 2014-05-11.22:38:56

ehashman commented 10 years ago

We're now on Django 1.5, so we can probably fix this now. Seems bitesize, so I'll add that label.

ankitjavalkar commented 9 years ago

@ehashman I would like to work on this bug. So based on my communication with @shaunagm, what I understood is that - I need to find all references to signals.post_save and signals.pre_save in our code, verify that there are no table modifications in the methods where signals.post_save and signals.pre_save are called. In case there are any table modifications - I should pass raw=True as an argument wherever signals.post_save and signals.pre_save are called? Am I right?

ehashman commented 9 years ago

Hi @ankitjavalkar! I saw your ping on IRC this morning so I just wanted to quickly get back to you here.

I would start with git grepping for all instances of signals.pre_save and post_save and checking how they are used. According to the docs linked above:

raw A boolean; True if the model is saved exactly as presented (i.e. when loading a fixture). One should not query/modify other records in the database as the database might not be in a consistent state yet.

so it seems to me that at least one table will always be modified when these methods are called; the concern is whether or not it should be affecting others (due to, perhaps, a FK relationship or something).

If you submit a PR I'll do my best to review it and give you feedback quickly.