Re: Magic Word / trackback plugin
Ryan Barrett <pyblosxom-6sb6M7qyT/[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.devel |
|---|---|
| Message-ID | <[email protected]> |
thank you! i tested the patches, and they worked. i committed them with a few
minor tweaks. i also added the trackback_reject callback to xmlrpc_pingback.
(sorry for the delay; i've been on vacation. :P)
On Thu, 21 Dec 2006, Junji NAKANISHI wrote:
> Hello,
>
> I made two patches about the 2nd idea which shunuhs explained.
>
> 1. move the comment_reject out of writeComments()
>
> --- comments.py.orig Thu Dec 21 03:03:47 2006
> +++ comments.py Thu Dec 21 03:09:12 2006
> @@ -359,19 +359,6 @@
> os.makedirs(cdir)
>
> cfn =
> os.path.join(cdir,entry['fn']+"-"+comment['pubDate']+"."+config['comment_draft_ext'])
> -
> - argdict = { "request": request, "comment": comment }
> - reject = tools.run_callback("comment_reject",
> - argdict,
> - donefunc=lambda x:x != 0)
> -
> - if (isinstance(reject, tuple) or isinstance(reject, list)) and
> len(reject) == 2:
> - reject_code, reject_message = reject
> - else:
> - reject_code, reject_message = reject, "Comment rejected."
> -
> - if reject_code == 1:
> - return reject_message
>
> def makeXMLField(name, field):
> return "<"+name+">" + cgi.escape(field.get(name, "")) +
> "</"+name+">\n";
> @@ -714,8 +701,20 @@
> cdict['email'] = form['email'].value
>
> cdict['ipaddress'] = pyhttp.get('REMOTE_ADDR', '')
> - data["comment_message"] = writeComment(request, config, data, \
> - cdict, encoding)
> +
> + argdict = { "request": request, "comment": cdict }
> + reject = tools.run_callback("comment_reject",
> + argdict,
> + donefunc=lambda x:x != 0)
> + if (isinstance(reject, tuple) or isinstance(reject, list)) and
> len(reject) == 2:
> + reject_code, reject_message = reject
> + else:
> + reject_code, reject_message = reject, "Comment rejected."
> + if reject_code == 1:
> + data["comment_message"] = reject_message
> + else:
> + data["comment_message"] = writeComment(request, config, data, \
> + cdict, encoding)
>
> def massage_link(linkstring):
> """Don't allow html in the link string. Prepend http:// if there isn't
>
>
> 2. add the trackback_reject hook to trackback plugin
>
> --- trackback.py.orig Thu Dec 21 03:03:47 2006
> +++ trackback.py Sun Dec 17 03:59:27 2006
> @@ -96,6 +96,19 @@
> 'link' : form['url'].value, \
> 'source' : form.getvalue('blog_name', ''), \
> 'description' : form.getvalue('excerpt', '') }
> +
> + argdict = { "request": request, "comment": cdict }
> + reject = tools.run_callback("trackback_reject",
> + argdict,
> + donefunc=lambda x:x != 0)
> + if (isinstance(reject, tuple) or isinstance(reject, list)) and
> len(reject) == 2:
> + reject_code, reject_message = reject
> + else:
> + reject_code, reject_message = reject, "Trackback rejected."
> + if reject_code == 1:
> + print >> response, tb_bad_response % reject_message
> + return 1
> +
> from Pyblosxom.entries.fileentry import FileEntry
> from Pyblosxom.pyblosxom import Request
> from Pyblosxom.pyblosxom import PyBlosxom
>
>
>
> I tested them by my blog and they had no problems. Please apply them for next
> release.
>
>
>>> # This idea is from Junji who send patch for trackback plugin recently.
>>> # He will send his patch hopefully :-)
>>>
>>> This problem was occurs for both trackback and comments plugins use
>>> writeComments() in the comments plugin and have judged whether the data
>>> is rejected.
>>>
>>> Then, the judgement code for comment reject move out of writeComments(),
>>> and add judgement for trackback reject to trackback plugin.
>>
>> agreed, this sounds like the right idea. we can either move the code that
>> calls cb_reject out of writeComments(), or leave it in and find another way
>> for trackback to tell the comments plugin that it's not spam.
>>
>> either way, it's definitely better than forcing all spam filter plugins to
>> special-case trackbacks.
>
>
> # shunuhs, thank you for you explained my idea in place of me!
>
>
-Ryan
--
http://snarfed.org/
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV