Jeremy Dunck
2007-11-13 02:31:06 UTC
I have a few places that override Model.save to do additional work
after the normal functionality.
I needed to add a post_save handler to do even more stuff after that
additional work, but ran into the obvious problem: post_save is
called at the end of Model.save, and that's before the additional work
in the override was done.
Example:
============
class MyModel(Model):
def save(self):
super(MyModel, self).save()
#extra work here
def even_more(sender,instance):
#stuff that depends on extra work having already occurred
dispatcher.connect(post_save, even_more_stuff)
==============
I feel OK about having to manually call post_save when I override
Model.save, but adding it now just results in post_save being called
twice.
Perhaps Model.save(raw=False) should become Model.save(raw=False,
fire_signals=True), leaving it up to the overrider to decide the
policy?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to django-developers-/***@public.gmane.org
To unsubscribe from this group, send email to django-developers-unsubscribe-/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---
after the normal functionality.
I needed to add a post_save handler to do even more stuff after that
additional work, but ran into the obvious problem: post_save is
called at the end of Model.save, and that's before the additional work
in the override was done.
Example:
============
class MyModel(Model):
def save(self):
super(MyModel, self).save()
#extra work here
def even_more(sender,instance):
#stuff that depends on extra work having already occurred
dispatcher.connect(post_save, even_more_stuff)
==============
I feel OK about having to manually call post_save when I override
Model.save, but adding it now just results in post_save being called
twice.
Perhaps Model.save(raw=False) should become Model.save(raw=False,
fire_signals=True), leaving it up to the overrider to decide the
policy?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django developers" group.
To post to this group, send email to django-developers-/***@public.gmane.org
To unsubscribe from this group, send email to django-developers-unsubscribe-/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---