wbgpagerを使うようにした
posted by jun-g at Sun, 06 Jul 2008 03:24 JST
前からこのブログにページャが付いていない事が気になっていたので、今更ながらページャのプラグインを使うようにした。追加したプラグインはwbgpager。
最初、エラーも出ないのにページャが全然表示されず、ちょっとハマった。使用しているPyBlosxomのバージョンが古いせいかな、と思い、一つ前のバージョン(2007-11-30)のwbgpagerを使ってみると、ようやく動くようになった。
最近ブログを放置しすぎている気がするので、久々に色々手入れしようかな。
Google App EngineでPyBlosxomを動かす
posted by jun-g at Sun, 11 May 2008 06:20 JST
遅まきながら、Google App EngineのSDKで遊んでいます。入門記事を読みながらHello worldをこなし、次にPyBlosxomを動かしてみる事にしました。
まずはアプリケーションを配置するディレクトリを作成。
$ mkdir -p ~/gae/pb
次にPyBlosxomをダウンロードして展開し、先ほど作ったディレクトリの下に配置。
$ cd /tmp
$ fetch http://jaist.dl.sourceforge.net/sourceforge/pyblosxom/pyblosxom-1.4.3.tar.gz
$ tar zxvf pyblosxom-1.4.3.tar.gz
$ cp -R pyblosxom-1.4.3/Pyblosxom ~/gae/pb/.
データ用のディレクトリを作る。
$ mkdir -p ~/gae/pb/data/entries
config.pyを環境に合わせて書き換える。
$ cp /tmp/pyblosxom-1.4.3/web/config.py ~/gae/pb/.
$ vim config.py
datadirは"data/entries"と相対パスで指定。他はお好みで適当に。
次に~/gae/pbの直下にメインとなるモジュールpb.pyを作成。
import wsgiref.handlers
import Pyblosxom.pyblosxom
from google.appengine.ext import webapp
def main():
application = Pyblosxom.pyblosxom.PyBlosxomWSGIApp()
wsgiref.handlers.CGIHandler().run(application)
if __name__ == '__main__':
main()
同じく~/gae/pbの直下にapp.yamlを作成。
application: hello
version: 1
runtime: python
api_version: 1
handlers:
- url: /.*
script: pb.py
これで準備完了。~/gae/pb/data/entriesの下に適当に書いたエントリのファイルを置いて起動。
$ dev_appserver.py ~/gae/pb
INFO 2008-05-11 05:55:30,453 appcfg.py] Checking for updates to the SDK.
WARNING 2008-05-11 05:55:30,949 datastore_file_stub.py] Could not read datastore data from /tmp/dev_appserver.datastore
WARNING 2008-05-11 05:55:30,949 datastore_file_stub.py] Could not read datastore data from /tmp/dev_appserver.datastore.history
INFO 2008-05-11 05:55:30,954 dev_appserver_main.py] Running application hello on port 8080: http://localhost:8080
よし、ブラウザからアクセス!するとエラーが出る…。
...snip...
/home/jun-g/gae/pb/Pyblosxom/tools.py in ()
1282 __overlapped = pywintypes.OVERLAPPED()
1283 elif os.name == 'posix':
1284 import fcntl
1285 LOCK_EX = fcntl.LOCK_EX
1286 LOCK_SH = fcntl.LOCK_SH
fcntl undefined
: No module named fcntl
args = ('No module named fcntl',)
message = 'No module named fcntl'
fcntlというモジュールが使えないみたいなので、tools.pyを適当に書き換えてfcntlを使わないようにしてみる。
$ diff -u tools.py.orig tools.py
--- tools.py.orig 2008-05-11 05:59:14.000000000 +0900
+++ tools.py 2008-05-11 06:00:06.000000000 +0900
@@ -1281,10 +1281,9 @@
# is there any reason not to reuse the following structure?
__overlapped = pywintypes.OVERLAPPED()
elif os.name == 'posix':
- import fcntl
- LOCK_EX = fcntl.LOCK_EX
- LOCK_SH = fcntl.LOCK_SH
- LOCK_NB = fcntl.LOCK_NB
+ LOCK_EX = None
+ LOCK_SH = None
+ LOCK_NB = None
else:
raise RuntimeError("PortaLocker only defined for nt and posix platforms")
@@ -1299,10 +1298,10 @@
elif os.name =='posix':
def lock(f, flags):
- fcntl.flock(f.fileno(), flags)
+ pass
def unlock(f):
- fcntl.flock(f.fileno(), fcntl.LOCK_UN)
+ pass
# END portalocking block from Python Cookbook.
# %<-------------------------
でもってブラウザからアクセスすると、

動いた!という事で、今日はここまで。