跳转到主要内容

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 (3.0 kB 查看哈希值)

上传于 源码