Re: Trackback plugin broke?

Ted Leung <[email protected]>
Newsgroups gmane.comp.web.pyblosxom.user
Message-ID <[email protected]>
Hi Eric,

I think I found the problem.  Could you put the out.write back into 
pyblosxom.py and try this version of trackback.py?  The problem is that 
trackback wasn't writing to the new response object.  Let me know if 
this solves your problems.

Ted


On Mar 27, 2005, at 2:55 PM, will guaraldi wrote:

>
> Thanks for the heads up.  I don't know anything about the trackback 
> plugin, so we'll have to wait for Ted or someone else who knows more 
> about it to fix it and test it based on what you've said.
>
> /will
>
> On Thu, 24 Mar 2005, Eric Gaumer wrote:
>> I just installed pyblosxom a day or two ago. I was trying to get the
>> trackback plugin working last night but had nothing but grief.
>>
>> It seems it's broken at the moment. I even went of to Ted's site and 
>> test
>> out his trackback links (http://www.sauria.com/blog/) but they too 
>> were
>> bad.
>>
>> There seems to be a stray "Status: 200" string pushed to STDOUT which 
>> jams
>> the XML parser.
>>
>> Found this:
>>
>> out.write("Status: %s\n" % self.status)
>>
>> in pyblosxom.py
>>
>> Removing it doesn't seem to effect anything other than the fact that 
>> it
>> cure this trackback problem. On top of that I also found some 
>> problems in
>> the trackback.py plugin directly.  Patch follows:
>>
>> --- 
>> ../data/CVS/pyblosxom/contrib/plugins/comments/plugins/trackback.py 
>> 2005-03-11 19:06:12.000000000 -0800
>> +++ trackback.py        2005-03-24 00:37:08.000000000 -0800
>> @@ -48,6 +48,7 @@
>>     """
>>     request = args['request']
>>     pyhttp = request.getHttp()
>> +    form = request.getForm()
>>     config = request.getConfiguration()
>>
>>     urltrigger = config.get('trackback_urltrigger','/trackback')
>> @@ -57,9 +58,7 @@
>>         print "Content-type: text/xml"
>>         print
>>
>> -        form = cgi.FieldStorage()
>> -
>> -        message = "not trackback"
>> +       message = "not trackback"
>>         if form.has_key("title") and form.has_key("excerpt") and \
>>                form.has_key("url") and form.has_key("blog_name"):
>>             import time
>> @@ -70,11 +69,11 @@
>>                       'source' : form['blog_name'].value, \
>>                       'description' : form['excerpt'].value }
>>             from Pyblosxom.entries.fileentry import FileEntry
>> -            from Pyblosxom.Request import Request
>> +            from Pyblosxom.pyblosxom import Request
>>             from Pyblosxom.pyblosxom import PyBlosxom
>>
>>             datadir = config['datadir']
>> -
>> +
>>             from comments import writeComment
>>             try:
>>                 import os
>> @@ -85,7 +84,7 @@
>>                 entry = FileEntry(request, '%s.%s' % (path, ext), 
>> datadir )
>>                 data = {}
>>                 data['entry_list'] = [ entry ]
>> -                writeComment(request, config, data, cdict, 
>> config['blog_encoding'])
>> +                writeComment(request, config, data, cdict)
>>                 print tb_good_response
>>             except OSError:
>>                 message = 'URI '+path_info+" doesn't exist"
>>
>> This is CVS code, checked out a day or two ago. I'm not that familiar 
>> with
>> pyblosxom but I suspect this plugin is using older calls/methods? 
>> Don't
>> really know but these fixes cure my problems.
>>
>> 	-Eric
>>
>>
>>
>> -------------------------------------------------------
>> SF email is sponsored by - The IT Product Guide
>> Read honest & candid reviews on hundreds of IT Products from real 
>> users.
>> Discover which products truly live up to the hype. Start reading now.
>> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
>> _______________________________________________
>> pyblosxom-users mailing list
>> pyblosxom-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
>> https://lists.sourceforge.net/lists/listinfo/pyblosxom-users
>>
>
> -- 
> whatever it is, you can find it at http://www.bluesock.org/~willg/
> except Will--you can only see him in real life.
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real 
> users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> pyblosxom-users mailing list
> pyblosxom-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/pyblosxom-users
>
----
Ted Leung                          Blog: <http://www.sauria.com/blog>
PGP Fingerprint: 1003 7870 251F FA71 A59A  CEE3 BEBA 2B87 F5FC 4B42
This message is:  [ ] bloggable   [x] ask first    [ ] private
trackback.py (application/octet-stream, 3.3 KB)
"""
This plugin allows pyblosxom to process trackback pings.  You must have the 
comments plugin installed as well, although you don't need to enable comments 
on your blog in order for trackbacks to work

%<---------------------------------------------------------
py['trackback_urltrigger'] = "/trackback"
%<---------------------------------------------------------

"""
import cgi, os, os.path
from Pyblosxom import tools

tb_good_response = """<?xml version="1.0" encoding="iso-8859-1"?>
<response>
<error>0</error>
</response>"""

tb_bad_response = """<?xml version="1.0" encoding="iso-8859-1"?>
<response>
<error>1</error>
<message>%s</message>
</response>"""

def cb_start(args):
    request = args["request"]
    config = request.getConfiguration()
    logdir = config.get("logdir", "/tmp")
    logfile = os.path.normpath(logdir + os.sep + "trackback.log")

    tools.make_logger(logfile)

def verify_installation(request):
    config = request.getConfiguration()
    retval = 1

    # all config properties are optional
    if not config.has_key('trackback_urltrigger'):
        print("missing optional property: 'trackback_urltrigger'")

    return retval

def cb_handle(args):
    """

    @param args: a dict of plugin arguments
    @type args: dict
    """
    request = args['request']
    pyhttp = request.getHttp()
    config = request.getConfiguration()

    urltrigger = config.get('trackback_urltrigger','/trackback')

    path_info = pyhttp['PATH_INFO']
    if path_info.startswith(urltrigger):
        print "Content-type: text/xml"
        print

        form = request.getForm()

        message = "not trackback"

        if form.has_key("title") and form.has_key("excerpt") and \
               form.has_key("url") and form.has_key("blog_name"):
            import time
            cdict = { 'title': form['title'].value, \
                      'author': 'Trackback from %s' % form['blog_name'].value, \
                      'pubDate' : str(time.time()), \
                      'link' : form['url'].value, \
                      'source' : form['blog_name'].value, \
                      'description' : form['excerpt'].value }
            from Pyblosxom.entries.fileentry import FileEntry
            from Pyblosxom.pyblosxom import Request
            from Pyblosxom.pyblosxom import PyBlosxom

            datadir = config['datadir']

            from comments import writeComment    
            try:
                import os
                pi = path_info.replace(urltrigger,'')
                path = os.path.join(datadir, pi[1:])
                data = request.getData()
                ext = tools.what_ext(data['extensions'].keys(), path)
                entry = FileEntry(request, '%s.%s' % (path, ext), datadir )
                data = {}
                data['entry_list'] = [ entry ]
                writeComment(request, config, data, cdict, config['blog_encoding'])
                print >>request.getResponse(), tb_good_response
            except OSError:
                message = 'URI '+path_info+" doesn't exist"
                tools.log(message)
                print >>request.getResponse(), tb_bad_response % message

        else:
            tools.log(message)
            print >>request.getResponse(), tb_bad_response % message

        import sys
        sys.stdout.flush()
        # no further handling is needed
        return 1
    else:
        return 0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.