odt是TurboGears2的可插入应用程序,允许将.odt(openoffice/libreoffice)文档呈现为输出模板。
tgext.odt的Python项目详细描述
关于tgextadt
tgextadt是TurboGears2的一个可插入应用程序,它允许将.odt(openoffice/libreoffice)文档呈现为输出模板。
安装
tgextadt既可以从pypi安装,也可以从bitbucket安装:
pip install tgextodt
应该只对大多数用户有效
堵漏tgextadt
在您的应用程序中,config/app_cfg.py导入plug,然后在文件的end使用tgextadd调用plug:
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/templates中的example应用程序中,您应该在定义变量字段py3o.document.hello时提供名为about.odt的模板。
要在libreoffice中定义变量字段,您可以从菜单insert->;fields->;other->;variables中挖掘有关https://help.libreoffice.org/Writer/Variables的更多信息
对于更复杂的特性,比如for循环和更详细的报告内容,您需要阅读py3o库本身的文档http://py3otemplate.readthedocs.org/
现在您可以直接从/about或/about.odt下载输出