I have two functions in a signals.py module that I would like called
whenever instances of a number of models are saved or deleted.
Everything works as intended when I add all of this to each models.py
module:

from django.dispatch import dispatcher
from django.db.models import signals
from project.feed_summary.signals import create_feed_summary,
delete_feed_summary

class Foo(models.Model):
   ...

dispatcher.connect(create_feed_summary, sender=Foo,
signal=signals.post_save)
dispatcher.connect(delete_feed_summary, sender=Foo,
signal=signals.pre_delete)

However, I would really love have a tuple in settings.py something
like:

FEED_SUMMARY_SETTINGS = ('model_import_path',)

And just tack models onto that as necessary, with something like this
somewhere in the feed_summary app so that it is self-contained:

for m in FEED_SUMMARY_SETTINGS:
   dispatcher.connect(create_feed_summary, sender=m,
signal=signals.post_save)
   dispatcher.connect(delete_feed_summary, sender=m,
signal=signals.pre_delete)

Is this possible?  Advisable?  If so, where is the best place to drop
that code so the dispatchers don't just get garbage collected?

Thanks,
Jonathan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to