예제 #1
0
파일: comment.py 프로젝트: leveille/blog.v1
 def _to_python(self, values, state):
     # we're in the administrator
     if request.urlvars['action'] == 'save':
         return values
     
     # this is a known bug.  context object
     # is not being passed properly to the conf_helper method call
     # since I don't use akismet I'm leaving this alone for now
     if h.wurdig_use_akismet():
         from wurdig.lib.akismet import Akismet
         # Thanks for the help from http://soyrex.com/blog/akismet-django-stop-comment-spam/
         a = Akismet(h.wurdig_get_akismet_key(), wurdig_url=request.server_name)
         akismet_data = {}
         akismet_data['user_ip'] = request.remote_addr
         akismet_data['user_agent'] = request.user_agent
         akismet_data['comment_author'] = values['name']
         akismet_data['comment_author_email'] = values['email']
         akismet_data['comment_author_url'] = values['url']
         akismet_data['comment_type'] = 'comment'
         spam = a.comment_check(values['content'], akismet_data)
         if spam:
             raise formencode.Invalid(
                 self.message('invalid-akismet', state),
                 values, state
             )
     return values
예제 #2
0
파일: twforms.py 프로젝트: bdrydyk/wurdig
 def _to_python(self, values, state):
     # we're in the administrator
     if request.urlvars['action'] == 'save':
         return values
     
     if h.wurdig_use_akismet():
         from wurdig.lib.akismet import Akismet
         # Thanks for the help from http://soyrex.com/blog/akismet-django-stop-comment-spam/
         a = Akismet(h.wurdig_get_akismet_key(), wurdig_url=request.server_name)
         akismet_data = {}
         akismet_data['user_ip'] = request.remote_addr
         akismet_data['user_agent'] = request.user_agent
         akismet_data['comment_author'] = values['name']
         akismet_data['comment_author_email'] = values['email']
         akismet_data['comment_author_url'] = values['url']
         akismet_data['comment_type'] = 'comment'
         spam = a.comment_check(values['content'], akismet_data)
         if spam:
             raise Invalid(
                 self.message('invalid-akismet', state),
                 values, state
             )
     return values