携帯でRSSチェック
最近、携帯ではてなRSSをチェックすることが多くなってる。
そこで一言。
RSSに本文を入れてくれ!特に、こあぶろぐな人達。 以上。
| < | March 2006 | > | ||||
| Su | Mo | Tu | We | Th | Fr | Sa |
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 | 31 | |
| 2005: | 6 | 7 | 8 | 9 | 10 | 11 | 12 | |||||
| 2006: | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 2007: | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 2008: | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 2009: | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 2010: | 1 |

ちゃんとしたドキュメントがないんだけど、テンプレートファイルの 繰り返し使いたい部分を、 <!-- BEGIN myparams --> と <!-- END myparams --> で括っておくと必要に応じて追加できる。 また、ネストも可能。(ENDの時は<!-- END -->だけでもいいかも)
${top_title}
<!-- BEGIN days -->
<div class="day">
${days.title}: ${days.body}
<!-- BEGIN days.sections -->
<div class="section"> ${days.sections.title}</div>
<!-- END days.sections -->
</div>
<!-- END days -->
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
spytee_test.py
'''
import spytee
t = spytee.template('test.html')
t.assign_vars({'top_title': 'spytee test'})
for i in xrange(2):
days = {'title': 'title is %d'%i,
'body' : 'body is %d'%i}
t.set_block_vars('days', days)
sections = []
for j in xrange(3):
sections.append({'title': '[** %d **] title is %d'%(i,j)})
for s in sections:
t.set_block_vars('days.sections', s)
print t.display(1)
$ python spytee_test.py spytee test <div class="day"> title is 0: body is 0 <div class="section"> [** 0 **] title is 0</div> <div class="section"> [** 0 **] title is 1</div> <div class="section"> [** 0 **] title is 2</div> </div> <div class="day"> title is 1: body is 1 <div class="section"> [** 1 **] title is 0</div> <div class="section"> [** 1 **] title is 1</div> <div class="section"> [** 1 **] title is 2</div> </div>
あと、ソースを見るとIF/ELIF/ELSE/ENDIFとか、EQ/NE/LT/GTとか 使えそうなんだけど、まだよくわからないのでそのうち。
下のものを使って、 サンプルブログ(pine)を作ってみた 。
まだまだ作り途中ですが、動作サンプルということで。
Colubridは、WSGI request handlerでありフレームワークではありません。
template engineもDBへのAPIも含まれていません。
類似のprojectにweb.pyがあります
There is a similar project called web.py but it is very storange. Some stupid magic everywhere and it uses print to send output to the browser
web.pyのことをstorangeだと言ってはいますが、web.py風に書くことができる WebpyApplication Type もちゃんと用意されています。
# myapplication.py
from colubrid import BaseApplication, execute
class HelloWorld(BaseApplication):
def process_request(self):
self.request.write('Hello World')
app = HelloWorld
if __name__ == '__main__':
execute()
デバッグ用にHTTP Serverも内蔵しているので、下記のようにするとapache等が なくても動作させることができます。
> python myapplication.py runserver
また、fcgiやmod_pythonじゃなくて普通のcgiとして動作させたい場合には 下記のようにして作成したcgiファイルを呼び出すことでcgiとして動作 させることが可能です。
> python myapplication.py genhandler > myapplication.cgi
myapplication.cgi
#!/usr/bin/python
import os
import sys
from colubrid.server import CGIServer
from myapplication import app
try:
from myapplication import exports
except ImportError:
exports = {}
奥さんが、ノートパソコンを一台買ってもいいよって言ってくれたので 何を買おうか考え中。Macも触ったことないけどちょっとおもしろそうだ。 intel入ってるになるまで待ったほうがいいんか?とか。どうしよう。