def edit(self, author, email, url, body, date, publish=1, REQUEST=None):
     """ Editor """
     self.author = author
     self.email = email
     self.author_url = url
     self.body = cleanCommentBody(self, body)
     self.date = DateTime.DateTime(date)
     self.published = publish
     self.reindex_object()
     if REQUEST is not None:
         url = REQUEST.HTTP_REFERER.split('?')[0]
         return REQUEST.RESPONSE.redirect(url+'?msg=%s' % 'Comment edited successfully')
def manage_addComment(self, author, body, url='',
                      email='', date=None, bitakora_cpt='',
                      random_cpt='', captcha_zz=0, REQUEST=None):
    """ Called from HTML form when commenting """
    from utils import checkNewCaptchaValue, isCommentSpam

    if self.CAPTCHA_ENABLED:
        if not checkNewCaptchaValue(self, bitakora_cpt):
            if REQUEST is not None:
                return REQUEST.RESPONSE.redirect(self.absolute_url()+u'?msg=%s&body=%s&comment_author=%s&comment_email=%s&comment_url=%s#bitakora_cpt_control' % (self.gettext('Are you a bot? Please try again...'), url_quote(body.encode('utf-8')), url_quote(author.encode('utf-8')), url_quote(email.encode('utf-8')), url_quote(url.encode('utf-8'))))

            return None

    # Publish the comment by default
    publish = 1

    if isCommentSpam(body, author, email, url, self.blogurl(), REQUEST):
        from zLOG import LOG, INFO
        LOG('manage_addComment', INFO, 'Spam: %s' % body)

        if REQUEST is not None:
            return REQUEST.RESPONSE.redirect(self.absolute_url()+u'?msg=%s&body=%s&comment_author=%s&comment_email=%s&comment_url=%s#bitakora_cpt_control' % (self.gettext('Are you a bot? Please try again...'), url_quote(body.encode('utf-8')), url_quote(author.encode('utf-8')), url_quote(email.encode('utf-8')), url_quote(url.encode('utf-8'))))

        return 0

    newauthor = clean(author)
    newbody = cleanCommentBody(self, body)
    newurl = cleanURL(url)
    newemail = cleanEmail(email)
    if date is None:
        newdate = DateTime.DateTime()
    else:
        newdate = DateTime.DateTime(date)
    newid = self.createCommentId()

    if self.commentsModerated():
        publish = 0

    comment = Comment(newid, newauthor, newemail, newurl,
                      newbody, newdate, self.getId(), publish)
    self._setObject(str(newid), comment)

    comment = getattr(self, str(newid))

    try:
        mailhost = self.MailHost
        from EpozPostTidy import cleanHTML

        mTo = self.contact_mail
        if self.inCommunity():
            mFrom = self.admin_mail
        else:
            mFrom = self.contact_mail

        variables = {}
        variables['from'] = mFrom.encode('utf-8')
        variables['to'] = mTo.encode('utf-8')
        variables['comment_author'] = newauthor.encode('utf-8')
        variables['comment_email'] = newemail.encode('utf-8')
        variables['comment_url'] = newurl.encode('utf-8')
        variables['comment_body'] = cleanHTML(newbody).encode('utf-8')
        variables['comment_address'] = comment.absolute_url()

        mSubj = self.gettext('New comment in your blog!')
        mMsg = self.comment_email_template(self, **variables)

        notifyByEmail(mailhost, mTo.encode('utf-8'), mFrom.encode('utf-8'),
                      mSubj.encode('utf-8'), mMsg.encode('utf-8'))
    except Exception, e:
        # If there is no MailHost, or other error happened
        # there won't be e-mail notifications
        from logging import getLogger
        log = getLogger('manage_addComment')
        log.info('Error sending e-mail: %s' % e)