Sphinx1.1からは、日本語もちゃんと検索出来るようになったので、
隠していた検索ボックスを表示するようにしました。
Sphinxの検索機能では、
conf.pyでhtml_copy_source = Trueを指定していると、
検索時に検索結果を表示してくれます。
この結果表示は、ソースファイルのコピーを参照して、
そのままhtmlに表示しているので、
ソースとhtmlの文字コードを変えていると、文字化けが発生します。
その対策方法を書きます。
トレーディングカードゲーム「Magic:The Gathering」の攻略サイト MTG-Guild の 開発日誌です。 Google App Engine - Python で構築スタート! ・・・どうなることやら
class TestUnicode(unicode): def __init__(self, x): print x
>>> a = TestUnicode('a') a >>> a u'a' >>> b = TestUnicode(x='b') Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'x' is an invalid keyword argument for this function
この一文
SyntaxHighlighter.config.bloggerMode = true;
from google.appengine.ext.ndb.model import (Model as _NdbModel, transactional) class Model(NdbModel): u"""google.appengine.ext.db.Modelの動きを真似るラッピング ぶっちゃけ、こんなラッピングはしないほうが良いと思います """ def __init__(self, **kwds): _kwds = kwds.copy() key_name = _kwds.get('key_name') if key_name != None: _kwds['id'] = key_name del(_kwds['key_name']) NdbModel.__init__(self, **_kwds) @classmethod def get_by_key_name(cls, key_name, **kwds): return cls.get_by_id(id=key_name, parent=kwds.get('parent')) @classmethod @transactional def insert_or_fail(cls, id_or_keyname, **kwds): u"""挿入して挿入された値を返します。 キー重複は、何もせずにNullを返します。全然非同期じゃないし、動作未検証です。 """ entity = cls.get_by_id(id=id_or_keyname, parent=kwds.get('parent')) if entity is None: entity = cls(id=id_or_keyname, **kwds) entity.put() return entity return None