[PATCH] Trackback+akismetcomments

Michael Guntsche <mike-Z92qn3yYq0hWk0Htik3J/[email protected]>
Newsgroups gmane.comp.web.pyblosxom.devel
Message-ID <[email protected]>
Hello,

I found out that trackback+akismetcomments do not really like each  
other in current trunk, well to be honest I think this was a love/ 
hate relationship from the beginning.
Here's a patch that makes them brings some harmony back in this  
relationship.
Please take a look at it and comment, especially you Ryan.

Kind regards,
Michael

Index: plugins/comments/plugins/akismetcomments.py
===================================================================
--- plugins/comments/plugins/akismetcomments.py	(revision 1144)
+++ plugins/comments/plugins/akismetcomments.py	(working copy)
@@ -86,31 +86,40 @@
      form = request.getForm()
      reqdata = request.getData()
      http = request.getHttp()
+
+    fields = {
+              # For Comments
+              'body' : 'comment',
+              'email' : 'comment_author_email',
+              'author' : 'comment_author',
+
+              # For Trackbacks
+              'excerpt' : 'comment',

-    fields = { 'comment' : 'body',
-               'comment_author_email' : 'email',
-               'comment_author' : 'author',
-               'comment_author_url' : 'url' }
+              # Common
+              'url': 'comment_author_url'
+              }
+
      data = {}
-    for field in fields:
-        if form.has_key(fields[field]):
-            data[field] = ""
-            for char in list(form[fields[field]].value):
+    for field, entry in fields.items():
+        if form.has_key(field):
+            data[entry] = ""
+            for char in list(form[field].value):
                  try:
                      char.encode('ascii')
                  except:
-                    data[field] = data[field] + "&#" + str(ord 
(char)) + ";"
+                    data[entry] = data[entry] + "&#" + str(ord 
(char)) + ";"
                  else:
-                    data[field] = data[field] + char
+                    data[entry] = data[entry] + char

-    if data.has_key('comment') and not data['comment']:
+    if data.has_key('comment') and data['comment']:
+        body = data['comment']
+    else:
          return False
-    else:
-        body = data['comment']

      data['user_ip'] = comment['ipaddress']
-    data['user_agent'] = http['HTTP_USER_AGENT']
-    data['referrer'] = http['HTTP_REFERER']
+    data['user_agent'] = http.get('HTTP_USER_AGENT','')
+    data['referrer'] = http.get('HTTP_REFERER','')

      api_key = config.get('akismet_api_key')
      base_url = config.get('base_url')
Index: plugins/comments/plugins/trackback.py
===================================================================
--- plugins/comments/plugins/trackback.py	(revision 1144)
+++ plugins/comments/plugins/trackback.py	(working copy)
@@ -103,6 +103,8 @@
                        'source' : form.getvalue('blog_name', ''), \
                        'description' : form.getvalue('excerpt', '') }

+            cdict['ipaddress'] = pyhttp.get('REMOTE_ADDR', '')
+
              argdict = { "request": request, "comment": cdict }
              reject = tools.run_callback("trackback_reject",
                                          argdict,

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4

_______________________________________________
Pyblosxom-devel mailing list
Pyblosxom-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/pyblosxom-devel
smime.p7s (application/pkcs7-signature, 2.4 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.