Hi,

I'm using CoreBlog2 0.9b for Plone, and I get spammed with trackback pinging. 
I've disable trackback in my entries (cannot add/hidden), but I'm still 
receiving mail notifications. So I dig a little and found a possible bug (at 
least annoyance), in the tbping python script:
  
  1. the script first sends mail notification
  2. then tries to add the trackback

I would have expected: try *then* notify. More, while adding trackback, the 
script isn't interrested into the return value of addTrackback2Entry(). As a 
result, event if the trackback is closed/hidden (that is, not open), the script 
won't be aware about this error (addTrackback2Entry() will return None), and 
will return a tbping_result with error code ok.

FWIW, attached is my customized tbping script.

Hope it helps,

Cheers,

Seb
-- 
Sébastien LELONG
sebastien.lelong[at]sirloon.net
http://www.sirloon.net
http://sirbot.org
"Syntactic sugar is just sugar, but it makes life tasty..."
:wq!
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.utils import log

cbtool = getToolByName(context, 'coreblog2_tool')

REQUEST = context.REQUEST
form = REQUEST.form
RESPONSE = context.REQUEST.RESPONSE
entry = context

excerpt = ''
if form.has_key('excerpt'):
    excerpt = form['excerpt']

title = cbtool.convert_charcode(form['title'])
blog_name = cbtool.convert_charcode(form['blog_name'])
excerpt = cbtool.convert_charcode(excerpt)

#Try to add trackback
try:
    if entry.addTrackback2Entry(title=title,url=form['url'],\
                            blog_name=blog_name,excerpt=excerpt) is None:
        raise Exception("Unable to tbping. Trackback closed ?")

    #Send notify mail if need
    if context.getSend_trackback_notification():
        try:
            to_addr   = context.getNotify_to()
            from_addr = context.getNotify_to()
            msgbody = context.translate('trackback_notify_body')
            elements = {}
            for k in ('blog_name','title','excerpt','url','excerpt'):
                if 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('trackback_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/tbping: '
                     'Some exception occured, %s' % e )

    return context.tbping_result(client=context,REQUEST=REQUEST,\
                                        error_code=0,message='Thanks :-)')
except:
    return context.tbping_result(client=context,REQUEST=REQUEST,\
                                    error_code=1,message='Error occured...')

Attachment: signature.asc
Description: Digital signature

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

Reply via email to