Skip to content

validate_online_file

ValidateOnlineFile

Bases: OptionalPyblishPluginMixin, InstancePlugin

Validate that product doesn't exist yet.

Source code in client/ayon_traypublisher/plugins/publish/validate_online_file.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class ValidateOnlineFile(OptionalPyblishPluginMixin,
                         pyblish.api.InstancePlugin):
    """Validate that product doesn't exist yet."""
    label = "Validate Existing Online Files"
    hosts = ["traypublisher"]
    families = ["online"]
    order = ValidateContentsOrder

    optional = True

    def process(self, instance):
        if not self.is_active(instance.data):
            return
        project_name = instance.context.data["projectName"]
        folder_id = instance.data["folderEntity"]["id"]
        product_entity = ayon_api.get_product_by_name(
            project_name, instance.data["productName"], folder_id)

        if product_entity:
            raise PublishValidationError(
                "Product to be published already exists.",
                title=self.label
            )