[COREblog-en] Comment reply handling
Niklas
nekstrand at gmail.com
Sat Dec 23 14:00:38 CET 2006
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 <nyusuke at nagosui.org> 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: nyusuke at nagosui.org
> web : http://nagosui.org
> _______________________________________________
> COREblog-en mailing list
> COREblog-en at postaria.com
> http://postaria.com/mailman/listinfo/coreblog-en
> Unsubscription writing to coreblog-en-leave at postaria.com
>
--
With best regards / med vänlig hälsning
Niklas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://postaria.com/pipermail/coreblog-en/attachments/20061223/489e58e9/attachment.htm
More information about the COREblog-en
mailing list