module documentation

_filtermanager.py - ZMS Import/Export Filter Pipeline Helpers

This module provides the procedural building blocks that execute configured filter pipelines during import/export. A pipeline consists of ordered process steps (commands, methods, scripts) and optional transformation files.

The module-level functions handle file-based processing and command execution, while FilterItem integrates those helpers with object export context and request/session state.

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

Class FilterItem Mixin exposing helper methods to initialise and execute filter exports.
Function exportFilter Run the export pipeline and return downloadable file payload metadata.
Function getTransFilename Build the filesystem path for a transformation resource.
Function importFilter Run the import pipeline for one configured filter.
Function processCommand Execute an external command-based process step on a file.
Function processData Process raw bytes data with one configured process step.
Function processFile Process one file using the configured command for a process id.
Function processFilter Execute all process steps configured for a filter definition.
Function processMethod Execute a method/script-based process step with request-bound file markers.
def exportFilter(self, id, REQUEST): (source)

Run the export pipeline and return downloadable file payload metadata.

Parameters
self:objectContext object exposing filter manager and export helpers.
id:strFilter id to execute.
REQUEST:ZPublisher.HTTPRequestActive request context.
Returns
tupleTuple (filename, data, content_type).
def getTransFilename(self, folder, trans): (source)

Build the filesystem path for a transformation resource.

Parameters
self:objectContext object providing logging utilities.
folder:strWorking directory used by the current filter run.
trans:objectTransformation object with an id in <process-id>.<nr>.<filename> format.
Returns
strAbsolute transformation filename inside folder.
def importFilter(self, filename, id, REQUEST): (source)

Run the import pipeline for one configured filter.

Parameters
self:objectContext object exposing filter manager.
filename:strSource filename to import/process.
id:strFilter id.
REQUEST:ZPublisher.HTTPRequestActive request context.
Returns
strFinal processed filename.
def processCommand(self, filename, command): (source)

Execute an external command-based process step on a file.

Placeholders supported in command include {in}, {out}, {cur_dir}, {package_home}, and {instance_home}.

Parameters
self:objectContext object exposing configuration and logging.
filename:strInput filename passed into the command.
command:strCommand template containing replacement markers.
Returns
strFinal output filename (or original input filename on failure).
def processData(self, processId, data, trans=None): (source)

Process raw bytes data with one configured process step.

Parameters
self:objectContext object exposing filter manager and configuration.
processId:strFilter-process id to execute.
data:bytes | strInput payload written to a temporary input file.
trans:object | NoneOptional transformation object written to disk and referenced by the process command.
Returns
bytesProcessed payload read from the resulting output file.
def processFile(self, processId, filename, trans=None): (source)

Process one file using the configured command for a process id.

Parameters
self:objectContext object exposing filter manager.
processId:strFilter-process id whose command is executed.
filename:strInput filename.
trans:object | NoneOptional transformation object referenced by command.
Returns
strOutput filename.
def processFilter(self, ob_filter, folder, filename, REQUEST): (source)

Execute all process steps configured for a filter definition.

Parameters
self:objectContext object exposing filter manager.
ob_filter:dictFilter definition containing id and process assignments.
folder:strWorking folder used during filter execution.
filename:strInput filename passed through each process step.
REQUEST:ZPublisher.HTTPRequestActive request context.
Returns
strFinal output filename after all process steps.
def processMethod(self, processId, filename, trans, REQUEST): (source)

Execute a method/script-based process step with request-bound file markers.

Parameters
self:objectContext object exposing filter manager.
processId:strFilter-process id to execute.
filename:strInput filename to be processed.
trans:object | NoneOptional transformation object used by the process.
REQUEST:ZPublisher.HTTPRequestActive request used to pass process variables.
Returns
strOutput filename selected by the process step.