食事会
posted by jun-g at Mon, 18 Dec 2006 02:11 JST
日曜日はいとこの結婚式、の後の披露宴代わりの食事会に参加してきた。
幸せそうで良いねぇとか思ってたけど、よく考えてみたら僕も今年の5月に式挙げたばっかりやった。なんかもっと前の事のような気がするな。
食事は中々おいしかった。お店は池田のビアンシュールというオーガニックフレンチレストランらしい。覚えとこ。
posted by jun-g at Mon, 18 Dec 2006 02:11 JST
日曜日はいとこの結婚式、の後の披露宴代わりの食事会に参加してきた。
幸せそうで良いねぇとか思ってたけど、よく考えてみたら僕も今年の5月に式挙げたばっかりやった。なんかもっと前の事のような気がするな。
食事は中々おいしかった。お店は池田のビアンシュールというオーガニックフレンチレストランらしい。覚えとこ。
posted by jun-g at Mon, 18 Dec 2006 02:03 JST
土曜日は、Ruby勉強会@関西-13に潜入参加してきた。
初心者っていうレベルじゃねーぞ!っていうか、文法も何も知らない、知っている事が「ruby」と「irb」というコマンドだけ、という状態で参加したのでどうなる事かと心配だったけど、何とかなったような気がする。
以下感想など。
posted by jun-g at Sun, 17 Dec 2006 04:39 JST
木曜に眼鏡屋から「眼鏡できたよ」との連絡が入ったので、金曜の夕方仕事を抜けて受け取りにいってきた。
今まで使ってた眼鏡よりよく見えるようになったし、かけ心地も良くていい感じ。昨日は早速この眼鏡をかけて出かけてきた。
posted by jun-g at Fri, 15 Dec 2006 03:30 JST
昨日、pyblosxomのSVN trunkにcheck_javascriptプラグインが新たに登録されてた。どうもJavaScriptを利用したコメントスパム対策用のプラグインみたい。という事は、こいつを利用すればMagicWordプラグインは不要、さらにtrackbackプラグインへの修正も不要って事かー!ムホムホ!!という事で早速試してみた。
まずはいつも通りcheck_javascript.pyをpluginsディレクトリにコピーして、config.pyを編集してプラグインがロードされるように設定。そして、コメントフォーム用のflavourであるcomment-form.htmlを、trunkの雛型を参考にして以下の通り修正。
--- comment-form.html.orig Sun Oct 15 02:59:40 2006
+++ comment-form.html Fri Dec 15 03:00:11 2006
@@ -3,7 +3,7 @@
<div class="blosxomCommentForm">
<form method="post" action="$base_url/$file_path.html#commentMessage" id="comments_form">
<fieldset>
-<input type="hidden" name="secretToken" value="pleaseDontSpam" />
+<input type="hidden" name="secretToken" id="secretTokenInput" value="pleaseDontSpam" />
<input name="parent" type="hidden" value="$file_path" />
<input name="title" type="hidden" value="$title" />
<label class="commentForm">Name</label><br />
@@ -21,6 +21,11 @@
<input name="submit" type="submit" value="Post" />
</fieldset>
</form>
+<script type="text/javascript"><!--
+// used by check_javascript.py. this is almost entirely backwards compatible,
+// back to 4.x browsers.
+document.getElementById("secretTokenInput").value = "$blog_title";
+//--></script>
</div> <!-- ends blosxomCommentForm div -->
</div>
</div> <!-- ends blosxomComments div -->
パラメータ「secretTokenInput」の値にJavaScriptで$blog_titleの値を設定し、プラグイン側のcb_comment_reject()で値をチェックする、という仕組みらしい。お手軽やね。あ、でもJavaScript使うって事は、テキストブラウザや古いブラウザからはコメント投稿できないって事かー!ま、いいか。
という事で、簡単さに惹かれてこいつを導入する事に決定。効果の程はこれいかに。
posted by jun-g at Tue, 12 Dec 2006 03:00 JST
先日のtrackback pluginのパッチは無事に取り込まれた模様。よかった。
そのパッチを作る際、trunkのcomments.pyを軽く見たんやけど、なんかメール送信時の非ASCII文字を受け付けない問題とか色々修正されてるっぽかったので、近々試してみないとなぁと思ってたら、shunuhsさんがtrunkに入れ替えた上にパッチを書いて、しかもtb spam用のプラグインまで作ってた。素晴らしいっす。仕事早いっす。動作実績があると心強いので、早速僕もtrunkのcomments/trackback pluginに入れ替える事にした。最近コメントスパムに悩まされていたので、ついでにMagicWord pluginも導入することに。
が、その前にshunuhsさんが「メールが飛ばない」と言われている問題を調べてみる事にした。テスト環境のcomments.pyをtrunkのものに入れ替えて試してみると、pyblosxomのエラーログに
2006-12-12 00:07:34,909 [ERROR] comments: error sending email: ['Traceback (most recent call last):\n', ' File "/pub/www/pyblosxom/plugins/comments.py", line 524, in send_email\n msg=body)\n', ' File "/usr/local/lib/python2.4/smtplib.py", line 692, in sendmail\n (code,resp) = self.data(msg)\n', ' File "/usr/local/lib/python2.4/smtplib.py", line 485, in data\n q = quotedata(msg)\n', ' File "/usr/local/lib/python2.4/smtplib.py", line 193, in quotedata\n re.sub(r\'(?:\\r\\n|\\n|\\r(?!\\n))\', CRLF, data))\n', ' File "/usr/local/lib/python2.4/sre.py", line 142, in sub\n return _compile(pattern, 0).sub(repl, string, count)\n', 'TypeError: expected string or buffer\n']
というのが出てた。どうもメール送信時にエラーになってるっぽい。で、なんとなくピンときて入れた修正が以下。
--- comments.py.orig Tue Dec 12 01:52:47 2006
+++ comments.py Tue Dec 12 02:36:47 2006
@@ -521,7 +521,7 @@
server = smtplib.SMTP(config['comment_smtp_server'])
server.sendmail(from_addr=email,
to_addrs=config['comment_smtp_to'],
- msg=body)
+ msg=body.as_string())
server.quit()
except Exception, e:
予想適中、無事にメール送信できるようになった。しかーし!現状のcomments.pyの作りだと、メールヘッダに設定されるべき「From」「To」「Subject」がメール本文に記載されるという超手抜き仕様。現状だとこんな本文のメールが来る。
From: from_at_aemonfreaks.com To: to_at_daemonfreaks.com Date: Mon, 11 Dec 2006 16:20:32 -0000 Subject: comment by TEST Name: TEST URL: Hostname: localhost.daemonfreaks.local (192.168.0.21) Entry URL: http://localhost/blog/200611060000 Comment location: /pub/www/pyblosxom/entries/comments/200611060000-1165854032.63.cmt Hello, world.
しかも件名が空。イケてない。先頭の4行は明らかにメールヘッダにあるべき。なので、以前自分で修正したやつと同様の修正を今回も入れる事にした。修正内容は以下のとおり。
--- comments.py.orig Tue Dec 12 01:52:47 2006
+++ comments.py Tue Dec 12 01:48:48 2006
@@ -475,13 +475,9 @@
comment_dir = os.path.join(config['comment_dir'], entry['absolute_path'])
# create the message
+ from email.Header import Header
from email.MIMEText import MIMEText
message = []
- message.append("From: %s" % email)
- message.append("To: %s" % config["comment_smtp_to"])
- message.append("Date: %s" % formatdate(float(comment['pubDate'])))
- message.append("Subject: comment by %s" % author)
- message.append("")
message.append("Name: %s" % author)
if comment.has_key('email'):
message.append("Email: %s" % comment['email'])
@@ -498,7 +494,13 @@
body = '\n'.join(message)
body = MIMEText(body.encode('utf-8'), 'plain', 'utf-8')
-
+ subj = "comment by %s" % author
+ subj = Header(subj.encode("utf-8"), "utf-8")
+ body["Subject"] = subj
+ body["From"] = config["comment_smtp_from"]
+ body["To"] = config["comment_smtp_to"]
+ body["Date"] = formatdate(float(comment['pubDate']))
+
if (config.has_key('comment_mta_cmd')):
argv = [config['comment_mta_cmd'],
'-s',
@@ -506,7 +508,7 @@
config['comment_smtp_to']]
# TODO: switch to subprocess when we can require python 2.4
process = popen2.Popen3(argv, capturestderr=True)
- process.tochild.write(body)
+ process.tochild.write(body.as_string())
process.tochild.close()
process.wait()
stdout = process.fromchild.read()
@@ -521,7 +523,7 @@
server = smtplib.SMTP(config['comment_smtp_server'])
server.sendmail(from_addr=email,
to_addrs=config['comment_smtp_to'],
- msg=body)
+ msg=body.as_string())
server.quit()
except Exception, e:
これで「Subject」「From」「To」(「Date」はオマケ)が正しくメールヘッダに設定されるようになった。ちなみに「comment_mta_cmd」を使用してメール送信を行う場合の動作は未確認なので、どなたか試してみてください…。
と、ここまで調べたところで時間切れになってしまった。続きは明日以降で。Magic Wordとtb_spam.pyの動作確認をしてから全部導入することにしよう。