[COREblog-en] Comment reply handling
Niklas
nekstrand at gmail.com
Fri Dec 22 12:05:22 CET 2006
Hi again,
This how i have solved it now, it probably could be done in a better way but
at least it seems to be working:
I have added the send mail function twice to be able to get the full
information to the blog admin but only the "comment added" and URL to the
commentators.
Also i have moved the send notification flag to commentators part as the
blog admin always should be notified but now i can turn off the commentator
notification.
I only have one small problem left, with this aproach the commentator gets a
notification mail even when he makes the comment himself, is there anyone
who knows an easy way to fix that, it would be very welcome :) .
---------------------------------------------------------------------------------------------
#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)
if context.getSend_comment_notification():
#Get email addresses
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:
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/21/06, Niklas <nekstrand at gmail.com> wrote:
>
> Thanx again,
>
> I have not had the time to check the last code but i'm sure it will work
> fine.
>
> The checkbox is also fine to leave out, the only problem would be if
> someone gets mail and tells me he don't like to have it, but they will have
> to live with it. I always have the possibility to erase their address in the
> comment.
>
> Is it ok if i add a feature request and adds this sample code? and adds
> you to the reference Mr NAKAI?
>
> /Niklas
>
>
>
> On 12/20/06, Yusuke NAKAI <nyusuke at nagosui.org> wrote:
> >
> > Hi,
> >
> > > I tried to find where to change to BCC but could not find the right
> > > reference, i agree with this beeing a problem, is it hard to change?.
> >
> > Notification mail is send by cbtool.send_mail() method:
> >
> > --------------------------------------------------
> > ...
> > 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, ...
> > ^^^^^^^^^^^^^^^^
> > --------------------------------------------------
> >
> > This method is defined in COREBlog2/COREBlogTool.py from line 238. And
> > this uses send() method of SecureMailHost. But this method can't handle
> > BCC.
> >
> > To handle BCC, using secureSend() method of SecureMailHost is needed.
> > But this approach seems to be a bit trouble. How about taking separate
> > sending approach?
> >
> > To send mail separately, you can use 'for' loop for addr_list.
> > For example:
> >
> > --------------------------------------------------
> > #Send notify mail if need
> > if context.getSend_comment_notification ():
> > try:
> > for addr in addr_list:
> > to_addr = addr
> > ...
> > --------------------------------------------------
> >
> >
> > > This might be to ask for to much but i will still ask, is it a hard
> > job
> > > to add a check box (notify me when furter comments are added to this
> > > post) in the comment form and have the mails selected bu this check
> > box?
> >
> > It seems to be hard. At least beyond my reach.
> >
> >
> > 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
>
--
With best regards / med vänlig hälsning
Niklas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://postaria.com/pipermail/coreblog-en/attachments/20061222/76ce87a8/attachment.htm
More information about the COREblog-en
mailing list