#9318: "Virtual" behaviour for signal dispatcher and model inheritance
-------------------------------------+--------------------------------------
Reporter: svetlyak40wt | Owner: nobody
Status: new | Milestone:
Component: Core framework | Version: 1.0
Resolution: | Keywords: model inheritance,
signals, dispatch
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------+--------------------------------------
Comment (by telenieko):
I guess you are talking about:
{{{
#!python
from django.db import models
class Parent(models.Model):
"""
>>> p = Parent(name="Hola")
>>> p.save()
Hello!
"""
name = models.CharField(max_length=10, blank=True, default='')
class Child(Parent):
"""
>>> p = Child(name="Hola ahora")
>>> p.save()
Hello!
"""
childname = models.CharField(max_length=10, blank=True, default='')
from django.db.models.signals import post_init
from django.db.models.signals import post_save
def say_hello(sender, *args, **kwargs):
print "Hello!"
post_save.connect(say_hello, sender=Parent)
}}}
?? The doctest that fails (the one in Child) should be considered a bug.
One would really expect that it's signal handlers still fire on a class
althought having been inherited (I'd guess that's how most languages
handle this).
A side, reading the docs about pre_init and post_init, you'd expect that
if you Model's __init__() method is run, handlers attached to this should
also be fired, which isn't the case.
So, in brief, handlers attached to a Model should be fired when signals
get sent from Child Models. Having it disabled by default can confuse
people, but maybe we could disable this until 2.0 :)
--
Ticket URL: <http://code.djangoproject.com/ticket/9318#comment:2>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---