module documentation

_exportable.py - ZMS Exportable Mixin

This module implements the Exportable mixin, which provides methods for exporting Zope objects to the filesystem, including binary files, images, and folder structures. It handles encoding, file writing, and recursive export of folder contents. The module also includes helper functions for localizing HTML content and managing export paths. The Exportable mixin can be used by ZMS content classes to enable export functionality.

License: GNU General Public License v2 or later, Organization: ZMS Publishing

Class Exportable Mixin that provides XML, HTML, and archive export helpers.
Function exportFiles Export binary file and image objects from a folder to the filesystem.
Function exportFolder Recursively export a Zope folder and its renderable objects.
Function findDelimiter Find the first occurrence of any delimiter in a string.
Function localHtml Convert rendered HTML to the charset configured for the request.
Function localIndexHtml Rewrite exported markup so links resolve in static HTML archives.
Function rfindDelimiter Find the last occurrence of any delimiter in a string.
Function writeFile Write export data to disk using the preferred encoding.
def exportFiles(self, root, id, path): (source)

Export binary file and image objects from a folder to the filesystem.

Parameters
selfUndocumented
root:OFS.ObjectManager.ObjectManagerContainer holding the exported folder.
id:strFolder id on the container.
path:strDestination directory.
def exportFolder(self, root, path, id, REQUEST, depth=0): (source)

Recursively export a Zope folder and its renderable objects.

Parameters
selfUndocumented
root:OFS.ObjectManager.ObjectManagerParent folder that contains the exported folder.
path:strBase export directory.
id:strFolder id to export.
REQUEST:ZPublisher.HTTPRequestCurrent request used to render templates.
depth:intAdditional relative path depth for nested exports.
def findDelimiter(s, delimiters=['"', '\'']): (source)

Find the first occurrence of any delimiter in a string.

Parameters
s:strText to search.
delimiters:listCandidate delimiter characters.
Returns
intPosition of the first delimiter or -1.
def localHtml(self, html): (source)

Convert rendered HTML to the charset configured for the request.

Parameters
selfUndocumented
html:str or bytesRendered markup.
Returns
bytes or strEncoded markup.
def localIndexHtml(self, obj, level, html, xhtml=False): (source)

Rewrite exported markup so links resolve in static HTML archives.

Parameters
selfUndocumented
obj:OFS.SimpleItem.ItemExported content object.
level:intRelative depth from the export root.
html:str or bytesRendered markup.
xhtml:boolFlag indicating XHTML export mode.
Returns
strLocalized markup with rewritten links.
def rfindDelimiter(s, delimiters=['"', '\'']): (source)

Find the last occurrence of any delimiter in a string.

Parameters
s:strText to search.
delimiters:listCandidate delimiter characters.
Returns
intPosition of the last delimiter or -1.
def writeFile(self, filename, data, mode='w', encoding='utf-8'): (source)

Write export data to disk using the preferred encoding.

Parameters
selfUndocumented
filename:strTarget file path.
data:str or bytesExport payload to persist.
mode:strFile open mode.
encoding:strText encoding used for unicode content.