Cumulative comments.py 1.3.0 patch that includes utf8 fix

Michael Olson <mwolson-mXXj517/[email protected]>
Newsgroups gmane.comp.web.pyblosxom.user
Message-ID <[email protected]>
I noticed that Benjamin Mako Hill had a patch that fixed a problem
with emailed comments not being sent properly
(http://mako.cc/copyrighteous/extra/comment_email_utf8_fix.diff).
I've modified it so that it keeps the same email syntax/content that
is present in contributed plugins pack 1.3.0.

This also includes a couple of minor message cleanups that I posted
previously.  I'm assuming that the developers have already applied the
BMH's patch and kept the original comment fields in the email, so this
is mainly to tide people over until the next contributed plugins pack
release.


-- 
Michael Olson -- FSF Associate Member #652 -- http://www.mwolson.org/
Interests: Emacs Lisp, text markup, protocols -- Jabber: mwolson_at_hcoop.net
  /` |\ | | | Projects: Emacs, Muse, ERC, EMMS, Planner, ErBot, DVC
 |_] | \| |_| Reclaim your digital rights by eliminating DRM.
      See http://www.defectivebydesign.org/what_is_drm for details.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
pyblosxom-users mailing list
pyblosxom-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/pyblosxom-users
signature.asc (application/pgp-signature, 188 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFV5Xw+1Ho2POo0xkRAgQMAJ9sB7h+lqqCaB4IWLM92dEOc760dACffGDC
bs630h3+AlN/BSa5EW9BC8M=
=e8vz
-----END PGP SIGNATURE-----
comments-1.3.0.diff (text/x-patch, 2.6 KB)
--- comments.py	2006-05-30 20:01:35.000000000 -0400
+++ comments.py	2006-11-12 16:29:24.000000000 -0500
@@ -464,12 +464,8 @@
         curl = config['base_url']+'/'+entry['file_path']
         comment_dir = os.path.join(config['comment_dir'], entry['absolute_path'])
 
+        # create the message body
         message = []
-        message.append("From: %s" % email)
-        message.append("To: %s" % config["comment_smtp_to"])
-        message.append("Date: %s" % formatdate(float(comment['pubDate'])))
-        message.append("Subject: comment by %s" % author)
-        message.append("")
         message.append("Name: %s" % author)
         if comment.has_key('email'):
             message.append("Email: %s" % comment['email'])
@@ -482,10 +478,23 @@
         message.append("Entry URL: %s" % curl)
         message.append("Comment location: %s" % comment_filename)
         message.append("\n\n%s" % description)
-        server.sendmail(from_addr=email,
-                        to_addrs=config['comment_smtp_to'], 
-                        msg="\n".join(message))
-        server.quit()
+
+        # encode the message
+        from email.MIMEText import MIMEText
+        body = "\n".join(message)
+
+        message = MIMEText(body.encode('utf-8'), 'plain', 'utf-8')
+        message['From'] =  email
+        message['To'] = config["comment_smtp_to"]
+        message['Date'] = formatdate(float(comment['pubDate']))
+        message['Subject'] = ("write back by %s" % author)
+
+        rv = server.sendmail(email,
+                             config['comment_smtp_to'], 
+                             message.as_string())
+
+        server.close()
+
     except Exception, e:
         logger = tools.getLogger()
         logger.error("error sending email: %s" % e)
@@ -642,8 +651,12 @@
  
     # second, we check to see if they're posting a comment and we
     # need to write the comment to disk.
-    if form.has_key("title") and form.has_key("author") and \
-        form.has_key("body") and not form.has_key("preview"):
+    if form.has_key("post"):
+        if not (form.has_key("title") and form.has_key("author") and \
+                    form.has_key("body") and not form.has_key("preview")):
+            data['comment_message'] = \
+                "Please fill out at least the Name and Comment fields."
+            return
 
         encoding = config.get('blog_encoding', 'iso-8859-1')
         decode_form(form, encoding)
@@ -748,6 +761,7 @@
     if form.has_key("email"):
         c['cmt_email'] = form['email'].value
     for key in c: entry[key] = c[key]
+    entry['comment_message'] = "A preview of your comment is available above."
 
     return c
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.