patch: allow cb_comment_reject to return a error message

Steven Armstrong <[email protected]>
Newsgroups gmane.comp.web.pyblosxom.devel
Message-ID <[email protected]>
Hi all

Any objections to the attached patch?

Thought it would be cool if plugins that implement cb_comment_reject 
could return some meaningfull error message why the comment was rejected.

Speak now or forever shall it be commited :)

cheers
Steven
1.3.2-comment-reject-tuple.patch (text/plain, 867 B)
Index: contrib/plugins/comments/plugins/comments.py
===================================================================
--- contrib/plugins/comments/plugins/comments.py	(revision 889)
+++ contrib/plugins/comments/plugins/comments.py	(working copy)
@@ -354,8 +354,14 @@
     reject = tools.run_callback("comment_reject",
                                 argdict,
                                 donefunc=lambda x:x)
-    if reject == 1:
-        return "Comment rejected."
+
+    if (isinstance(reject, tuple) or isinstance(reject, list)) and len(reject) == 2:
+        reject_code, reject_message = reject
+    else:
+        reject_code, reject_message = reject, "Comment rejected."
+
+    if reject_code == 1:
+        return reject_message
    
     def makeXMLField(name, field):
         return "<"+name+">" + cgi.escape(field.get(name, "")) + "</"+name+">\n";
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.