How to write a hook to run in this app
Ensure your collector.py
has added the settings for Background Processing:
"Background Processing": {
"type": "bool",
"default": False,
"description": "Boolean to turn on/off the background publishing process.",
},
}
The collector.py
also needs to write the values to the parent_item properties:
# store the Batch Processing settings in the root item properties
bg_processing = settings.get("Background Processing")
if bg_processing:
parent_item.properties["bg_processing"] = bg_processing.value
Make sure that each Publish Plugin
accesses the values in the publish and finalize methods:
# get the publish "mode" stored inside of the root item properties
bg_processing = item.parent.properties.get("bg_processing", False)
in_bg_process = item.parent.properties.get("in_bg_process", False)
Example to perform your File Save
only in the main Publish and not in the BG Publish:
# bump the session file to the next version
if not bg_processing or (bg_processing and not in_bg_process):
self._save_to_next_version(item.properties["path"], item, self.save_file)