On Thu, Apr 16, 2009 at 6:39 AM, koranthala <koranth...@gmail.com> wrote:

>
> Hi,
>    I was comparing between signal and save() and came across this
> following mail chain -
>
> http://groups.google.com/group/django-users/browse_thread/thread/d0ff6dd3432d25fa/99a92f9f4b343b1e
>
>    In this it is mentioned that -
> ---
> If you want to implement some
> functionality that operates across multiple types of models, you need
> to
> use the signal infrastructure, since the same signal is raised no
> matter
> what the type of model (you can differentiate the model type in the
> signal handler, though).
> ----
>
>   I was unable to understand why we should go for signals in case we
> have to work across models?
>   Say, for example - I have ModelA and ModelB. Everytime, I save an
> element in ModelA, I need to update 15 fields in ModelB.
>   In this case, shouldn't I do everything in ModelA.save itself?
> ModelA.save():
>   super.save()
>   Update 15 fields in ModelB
>
>   I do not understand why we should go for signals in this case too?
>   Sorry if I am dense :-)
>
>
> >
>
One of the simplest reasons to use signals in that situation is because you
can't change the code in that application.  Say you want to trigger
something on the User object being saved, you don't want to monkey patch
django.contrib.auth so use just use the signal for code clarity.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to