Thanx a lot to you all for the help,<br><br>It is now working very well, i (as blog administrator) get a comment notification with all information on every comment added, commentators get a notification of all added comments exept when they write their own but only with the url as information.
<br><br>Blog admin always gets a notification, commentator notification can be dissabled by send notification setting and by letting the commentators leave the email field empty (i have not tested the last option but i guess it would work).
<br><br>Here is the "final" code for the record:<br><br>-----------------------------------------------------<br>#Send notify mail to blog admin<br>try:<br> to_addr = context.getNotify_to()<br> from_addr =
context.getNotify_from()<br> msgbody = context.translate('comment_notify_body')<br> elements = {}<br> for k in ('title','author','url','body'):<br> if REQUEST.form.has_key
(k):<br> elements[k] = REQUEST.form[k]<br> else:<br> elements[k] = ''<br> elements['post_ip'] = REQUEST.getClientAddr()<br> elements['entry_url'] = context.absolute_url
()<br> msgbody = msgbody % (elements)<br> msgsubject = context.translate('comment_notify_title')<br> mgsheader = """To: %s<br>From: %s<br>Mime-Version: 1.0<br>Content-Type: text/plain; Charset=utf-8
<br><br>""" % (to_addr,from_addr)<br> cbtool.send_mail(mgsheader+msgbody, to_addr, from_addr, msgsubject)<br><br># check status of notification mail setting<br> if context.getSend_comment_notification
():<br><br>#Get email addresses for commentators<br> com_list = context.getComment()<br> addr_list = []<br> for com in com_list:<br> if not addr_list.count(com.getEmail()):<br> addr_list.append(
com.getEmail())<br><br>#Send notify mail if need to commentators<br><br> try:<br> for addr in addr_list:<br> if addr == REQUEST.form['email']:<br> continue<br> else:
<br> to_addr = addr<br> from_addr = context.getNotify_from()<br> msgbody = context.absolute_url()<br> msgsubject = context.translate('comment_notify_title')
<br> mgsheader = """To: %s<br>From: %s<br>Mime-Version: 1.0<br>Content-Type: text/plain; Charset=utf-8<br><br>""" % (to_addr,from_addr)<br> cbtool.send_mail
(mgsheader+msgbody, to_addr, from_addr, msgsubject)<br><br> except Exception,e:<br> log( 'COREBlog2/cbaddComment: '<br> 'Some exception occured, %s' % e )<br><br> <br>
except Exception,e:<br> log( 'COREBlog2/cbaddComment: '<br> 'Some exception occured, %s' % e )<br>-----------------------------------------------------<br><br><div><span class="gmail_quote">
On 12/23/06, <b class="gmail_sendername">Yusuke NAKAI</b> <<a href="mailto:nyusuke@nagosui.org">nyusuke@nagosui.org</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>>> for addr in addr_list:<br>>> if addr == REQUEST.form[email]:<br>><br>> This line should be...<br>><br>>> if addr == REQUEST.form['email']:<br><br>Sorry for my mistake...
<br><br>Regards,<br><br>--<br>Yusuke NAKAI<br><br>mail: <a href="mailto:nyusuke@nagosui.org">nyusuke@nagosui.org</a><br>web : <a href="http://nagosui.org">http://nagosui.org</a><br>_______________________________________________
<br>COREblog-en mailing list<br><a href="mailto:COREblog-en@postaria.com">COREblog-en@postaria.com</a><br><a href="http://postaria.com/mailman/listinfo/coreblog-en">http://postaria.com/mailman/listinfo/coreblog-en</a><br>
Unsubscription writing to <a href="mailto:coreblog-en-leave@postaria.com">coreblog-en-leave@postaria.com</a><br></blockquote></div><br><br clear="all"><br>-- <br>With best regards / med vänlig hälsning<br><br>Niklas