def wrapper(origin, request, *args, **kwargs): if request.POST and request.POST.get(param, None) and WORDPRESS_API_KEY and (not can_bypass_spam_check(request.user)): comment = smart_str(request.POST[param]) data = { "user_ip":request.META["REMOTE_ADDR"], "user_agent":request.environ['HTTP_USER_AGENT'], "comment_type": comment_type, "comment":comment } if request.user.is_authenticated(): data.update({ "comment_author":smart_str(request.user.username), "comment_author_email":request.user.email, "comment_author_url":request.user.website, }) api = Akismet(settings.WORDPRESS_API_KEY, APP_URL, "OSQA/%s" % OSQA_VERSION) api.baseurl = "api.antispam.typepad.com/1.1/" # http://meta.osqa.net/questions/8456/preparing-for-spam if api.comment_check(comment, data): post_data = request.POST captcha_form = SimpleCaptchaForm(request.POST) if request.is_ajax(): response = { 'success': False, 'error_message': _("Sorry, but akismet thinks your %s is spam.") % comment_type } return HttpResponse(simplejson.dumps(response), mimetype="application/json") else: captcha_checked = False try: if captcha_form.is_valid() and 'recaptcha' in captcha_form.fields.keys(): captcha_checked = True except: pass if not captcha_checked: return render_to_response('modules/akismet/foundspam.html', { 'action_name': comment_type, 'post_data' : post_data, 'captcha_form' : captcha_form, }, RequestContext(request)) return origin(request, *args, **kwargs)