_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 | |
Mixin exposing helper methods to initialise and execute filter exports. |
| Function | export |
Run the export pipeline and return downloadable file payload metadata. |
| Function | get |
Build the filesystem path for a transformation resource. |
| Function | import |
Run the import pipeline for one configured filter. |
| Function | process |
Execute an external command-based process step on a file. |
| Function | process |
Process raw bytes data with one configured process step. |
| Function | process |
Process one file using the configured command for a process id. |
| Function | process |
Execute all process steps configured for a filter definition. |
| Function | process |
Execute a method/script-based process step with request-bound file markers. |
Run the export pipeline and return downloadable file payload metadata.
| Parameters | |
| self:object | Context object exposing filter manager and export helpers. |
| id:str | Filter id to execute. |
| REQUEST:ZPublisher.HTTPRequest | Active request context. |
| Returns | |
| tuple | Tuple (filename, data, content_type). |
Build the filesystem path for a transformation resource.
| Parameters | |
| self:object | Context object providing logging utilities. |
| folder:str | Working directory used by the current filter run. |
| trans:object | Transformation object with an id in <process-id>.<nr>.<filename> format. |
| Returns | |
| str | Absolute transformation filename inside folder. |
Run the import pipeline for one configured filter.
| Parameters | |
| self:object | Context object exposing filter manager. |
| filename:str | Source filename to import/process. |
| id:str | Filter id. |
| REQUEST:ZPublisher.HTTPRequest | Active request context. |
| Returns | |
| str | Final processed filename. |
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:object | Context object exposing configuration and logging. |
| filename:str | Input filename passed into the command. |
| command:str | Command template containing replacement markers. |
| Returns | |
| str | Final output filename (or original input filename on failure). |
Process raw bytes data with one configured process step.
| Parameters | |
| self:object | Context object exposing filter manager and configuration. |
| process | Filter-process id to execute. |
| data:bytes | str | Input payload written to a temporary input file. |
| trans:object | None | Optional transformation object written to disk and referenced by the process command. |
| Returns | |
| bytes | Processed payload read from the resulting output file. |
Process one file using the configured command for a process id.
| Parameters | |
| self:object | Context object exposing filter manager. |
| process | Filter-process id whose command is executed. |
| filename:str | Input filename. |
| trans:object | None | Optional transformation object referenced by command. |
| Returns | |
| str | Output filename. |
Execute all process steps configured for a filter definition.
| Parameters | |
| self:object | Context object exposing filter manager. |
| ob | Filter definition containing id and process assignments. |
| folder:str | Working folder used during filter execution. |
| filename:str | Input filename passed through each process step. |
| REQUEST:ZPublisher.HTTPRequest | Active request context. |
| Returns | |
| str | Final output filename after all process steps. |
Execute a method/script-based process step with request-bound file markers.
| Parameters | |
| self:object | Context object exposing filter manager. |
| process | Filter-process id to execute. |
| filename:str | Input filename to be processed. |
| trans:object | None | Optional transformation object used by the process. |
| REQUEST:ZPublisher.HTTPRequest | Active request used to pass process variables. |
| Returns | |
| str | Output filename selected by the process step. |