Re: Re: problems with trackback
Joseph Reagle <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Organization | NYU |
| Message-ID | <[email protected]> |
On Saturday 09 April 2005 13:50, Eric Gaumer wrote:
> Dumb question but are you sure the trackback plugin is actually there?
Yep. BTW: the error message says:
[[[
ImportError: Bad magic number in /home/reagle/data/2web/pyblosxom-1.2/contrib.1.2/plugins/comments/plugins/trackback.pyc
__doc__ = "Import can't find module, or can't find name in module."
__getitem__ = <bound method ImportError.__getitem__ of <exceptions.ImportError instance>>
__init__ = <bound method ImportError.__init__ of <exceptions.ImportError instance>>
__module__ = 'exceptions'
__str__ = <bound method ImportError.__str__ of <exceptions.ImportError instance>>
args = ('Bad magic number in /home/reagle/data/2web/pyblo...ontrib.1.2/plugins/comments/plugins/trackback.pyc',)
]]]
***
That's in /home/reagle/data/2web/pyblosxom-1.2/contrib.1.2/plugins/comments/plugins/trackback.pyc which makes me think it can find it, but not something else. In any case, it works fine from the command line:
=== plugin: 'trackback'
file: /home/reagle/data/2web/pyblosxom-1.2/contrib.1.2/plugins/comments/plugins/trackback.pyc
plugin has no version.
PASS
The one Ted send me is attached.
trackback.py
(application/x-python, 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):
response = request.getResponse()
response.addHeader("Content-type", "text/xml")
form = request.getForm()
message = "not trackback: %s" % path_info
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 >> response, tb_good_response
except OSError:
message = 'URI '+path_info+" doesn't exist"
tools.log(message)
print >> response, tb_bad_response % message
else:
tools.log(message)
print >> response, tb_bad_response % message
# no further handling is needed
return 1
else:
return 0