-models.signals.post_save.connect(notify_new_comment, sender=XtdComment)
\ No newline at end of file
+models.signals.post_save.connect(notify_new_comment, sender=XtdComment)
+
+
+def spamfilter(sender, comment, **kwargs):
+ """Very simple spam filter. Just don't let any HTML links go through."""
+ if re.search(r"<a\s+href=", comment.comment):
+ fields = (comment.user, comment.user_name, comment.user_email,
+ comment.user_url, comment.submit_date, comment.ip_address,
+ comment.followup, comment.comment)
+ mail_managers(u"Spam filter report",
+ (u"""This comment was turned down as SPAM: \n""" +
+ """\n%s""" * len(fields) +
+ """\n\nYou don't have to do anything.""") % fields)
+ return False
+ return True
+comment_will_be_posted.connect(spamfilter)