Inheriting from comments breaks comment moderation
|Reported by:||Beetle_B||Owned by:||nobody|
|Severity:||Keywords:||comments inheritance moderation sprintdec2010|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I created a new kind of comment called TreeComment which (ultimately) subclasses Comment (in contrib.comments)
Essentially, I have a TreeCommentBase which subclasses Comment and is an abstract class. Then TreeComment subclasses TreeCommentBase. This is all in a custom app called treecomments.
Now in the moderation code, we have:
signals.comment_will_be_posted.connect(self.pre_save_moderation, sender=comments.get_model()) signals.comment_was_posted.connect(self.post_save_moderation, sender=comments.get_model())
which relies on get_model() which is defined in the init.py file in comments. This causes a wrong model to be sent (my model is TreeComment, not Comment).
If I replace it with treecomments.get_model() (and create that function under init.py - I needed it for something else anyway), then it all works.
Am I doing something wrong? Is there a more proper way of subclassing? For now I'll just subclass Moderator and customize to fix this...