Hi everyone, I'm using Django 1.0, and attempting to do some comment moderation with Akismet. When I try to wire up a pre_save signal, I'm getting an error saying 'instance' is not defined. Here is my code:
def moderate_comment(sender, **kwargs): if not instance.id: # <-- instance is not defined entry = instance.get_content_object() delta = datetime.datetime.now() - entry.pub_date if delta.days > 30: instance.is_public = False else: akismet_api = Akismet(key=settings.AKISMET_API_KEY, blog_url='http://%s/' % Site.objects.get_current().domain) if akismet_api.verify_key(): akistmet_data = {'comment_type' : 'comment', 'referrer' : '', 'user_ip' : instance.ip_address, 'user-agent' : ''} if akismet_api.comment_check(smart_str(instance.comment), akistmet_data, build_data=True): instance.is_public = False email_body = '%s posted a new comment on the entry %s.' mail_managers('New comment posted', email_body % (instance.user_name, instance.get_content_object())) models.signals.pre_save.connect(moderate_comment, sender=Comment) Not sure what I'm doing wrong, but I would appreciate an extra set of eyes. TIA, Brandon --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---