tgext.odt是TurboGears2的一个可插拔应用程序,允许将.odt(openoffice/libreoffice)文档渲染为输出模板。
项目描述
关于tgextodt
tgextodt是TurboGears2的一个可插拔应用程序,允许将.odt(openoffice/libreoffice)文档渲染为输出模板。
安装
tgextodt可以从pypi或从bitbucket安装
pip install tgextodt
对大多数用户来说应该能正常工作
插入tgextodt
在您的应用程序 config/app_cfg.py 中导入 plug,然后在 文件末尾 调用 plug 并使用tgextodt
from tgext.pluggable import plug plug(base_config, 'tgextodt')
用法
要使用odt模板,您需要在控制器中声明如下类型
@expose('odt:example.templates.about', content_type='application/vnd.oasis.opendocument.text') def about(self): response.headerlist.append(('Content-Disposition', 'attachment;filename=filename.odt')) return dict(hello='Hello World')
显然,在您的 example 应用程序中,在 example/templates 文件夹中,您应该提供一个名为about.odt的模板,其中您已定义了变量字段 py3o.document.hello。
要在libreoffice中定义变量字段,您可以在这里了解更多信息:[https://help.libreoffice.org/Writer/Variables](https://help.libreoffice.org/Writer/Variables),基本上是从菜单插入 -> 字段 -> 其他 -> 变量
对于更复杂的功能,如循环和更详细的报告内容,您需要阅读py3o库本身的文档:[http://py3otemplate.readthedocs.org/](http://py3otemplate.readthedocs.org/)
现在您可以直接从 /about 或 /about.odt 下载您的输出
项目详情
关闭
tgext.odt-0.3.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 2efbf9ff931406c844ab17b0a411748064b649e2a3bc51c6235115beffd0e898 |
|
MD5 | a580a9f024096ca8b95e26e2f747b88e |
|
BLAKE2b-256 | dac66e5c2359f6a3c19299e7bbd1aed67d3a94b26489309e6f9b379a8e186b57 |