<py:match path="foo">
<?python
import os
href = select('@href').render()
SOMEWHERE = ... # what file contained the foo tag?
path = os.path.abspath(os.path.join(os.path.dirname(SOMEWHERE), href)
f = file(path,'r')
# (do something interesting with f)
?>
</py:match>
...
<foo href="../path/relative/to/this/template/abcd.xyz"/>
上記の「どこか」とは何ですか?その属性は、他のタグの属性のようにhref、タグが含まれるファイルに相対的である必要があります。foohref
または、py:match ブロックが含まれているファイルはどれですか? fooタグ付きのファイルとは別のディレクトリにある可能性があるため、これはあまり良くありません。
さらに悪いことに、レンダリングしているファイルのパスを Genshi の外部からコンテキスト引数として指定することもできますが、それは上記の両方とは異なるディレクトリにある可能性があります。