Thanx a lot to you all for the help,

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.

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).

Here is the "final" code for the record:

-----------------------------------------------------
#Send notify mail to blog admin
try:
   to_addr   = context.getNotify_to()
   from_addr = context.getNotify_from()
   msgbody = context.translate('comment_notify_body')
   elements = {}
   for k in ('title','author','url','body'):
       if REQUEST.form.has_key(k):
           elements[k] = REQUEST.form[k]
       else:
           elements[k] = ''
   elements['post_ip'] = REQUEST.getClientAddr()
   elements['entry_url'] = context.absolute_url()
   msgbody = msgbody % (elements)
   msgsubject = context.translate('comment_notify_title')
   mgsheader = """To: %s
From: %s
Mime-Version: 1.0
Content-Type: text/plain; Charset=utf-8

""" % (to_addr,from_addr)
   cbtool.send_mail(mgsheader+msgbody, to_addr, from_addr, msgsubject)

# check status of notification mail setting
   if context.getSend_comment_notification():

#Get email addresses for commentators
       com_list = context.getComment()
       addr_list = []
       for com in com_list:
           if not addr_list.count(com.getEmail()):
               addr_list.append(com.getEmail())

#Send notify mail if need to commentators

       try:
           for addr in addr_list:
               if addr == REQUEST.form['email']:
                   continue
               else:
                   to_addr = addr
                   from_addr = context.getNotify_from()
                   msgbody = context.absolute_url()
                   msgsubject = context.translate('comment_notify_title')
                   mgsheader = """To: %s
From: %s
Mime-Version: 1.0
Content-Type: text/plain; Charset=utf-8

""" % (to_addr,from_addr)
                   cbtool.send_mail(mgsheader+msgbody, to_addr, from_addr,
msgsubject)

       except Exception,e:
            log( 'COREBlog2/cbaddComment: '
                    'Some exception occured, %s' % e )


except Exception,e:
   log( 'COREBlog2/cbaddComment: '
            'Some exception occured, %s' % e )
-----------------------------------------------------

On 12/23/06, Yusuke NAKAI <[EMAIL PROTECTED]> wrote:

Hi,

>> for addr in addr_list:
>>      if addr == REQUEST.form[email]:
>
> This line should be...
>
>>      if addr == REQUEST.form['email']:

Sorry for my mistake...

Regards,

--
Yusuke NAKAI

mail: [EMAIL PROTECTED]
web : http://nagosui.org
_______________________________________________
COREblog-en mailing list
[email protected]
http://postaria.com/mailman/listinfo/coreblog-en
Unsubscription writing to [EMAIL PROTECTED]




--
With best regards / med vänlig hälsning

Niklas
_______________________________________________
COREblog-en mailing list
[email protected]
http://postaria.com/mailman/listinfo/coreblog-en
Unsubscription writing to [EMAIL PROTECTED]

Reply via email to