webodt API

Shortcuts

webodt.shortcuts.render_to(format, template_name, dictionary=None, context_instance=None, delete_on_close=True, cache=<class 'webodt.cache.CacheManager'>, preprocessors=None)[source]

Convert the template given by template_name and dictionary to a document in given format. The document (file-like object) will be returned.

format is the filename extension. It’s possible to use “odt”, “pdf”, “doc”, “html” or “rtf” and probably more.

context_instance is the optional parameter which should contain instance of the subclass of django.template.Context.

delete_on_close defines whether the returned document should be deleted automatically when closed.

preprocessors is a list of preprocessors overriding WEBODT_ODF_TEMPLATE_PREPROCESSORS settings variable. Suitable for ODF documents only.

If the template_name ends with .html, template is considered as HTML template, otherwise as ODF based template.

webodt.shortcuts.render_to_response(template_name, dictionary=None, context_instance=None, filename=None, format='odt', cache=<class 'webodt.cache.CacheManager'>, preprocessors=None, inline=None)[source]

Using same options as render_to, return django.http.HttpResponse object. The document is automatically removed when the last byte of the response is read.

API

class webodt.ODFTemplate(template_name, preprocessors=None)[source]

ODF template class

__init__(template_name, preprocessors=None)[source]

Create object by the template name. The template name is relative to WEBODT_TEMPLATE_PATH directory.

template_name: name of the template to load and handle

get_content_xml()[source]

Return the content.xml file contents

render(context, delete_on_close=True)[source]

Return rendered ODF (webodt.ODFDocument instance)

class webodt.converters.ODFConverter[source]

Base class for all built-in converter backends

convert(document, format=None, output_filename=None, delete_on_close=True)[source]

convert document and return file-like object representing output document

webodt.converters.converter()[source]

Create and return Converter instance on a basis of WEBODT_CONVERTER settings variable

Table Of Contents

Previous topic

Quickstart guide

Next topic

Settings options

This Page