API
Search…
.data
Available to Instance and Context objects and used to pass data between library and plug-ins.

Introduction

Data is primarily gathered during Collection and used during subsequent plug-ins, such as Validation and Extraction. Data can also be used as a means of messaging across plug-ins.

Naming Convention

Data members are using mixedCase.
Wrong
1
instance.data["snake_case_is_for_python"] = True
2
instance.data["CamelCaseIsForClasses"] = False
Copied!
Right
1
instance.data["myVariable"] = True
2
instance.data["longName"] = 42
3
instance.data["veryLongVariable"] = 5
Copied!
The motivation is to separate between what is Python and what is Pyblish data.

Examples

1
import pyblish.api as pyblish
2
context = pyblish.Context()
3
context.data["myData"] = "myValue"
4
5
instance = pyblish.Instance(name="MyInstance", parent=context)
6
instance.data["range"] = [0, 120]
7
instance.data["active"] = False
Copied!
Data of any type may be added, including complex objects.
1
# Custom objects
2
3
import pyblish.api
4
5
class MyCustomChild(object):
6
def __init__(self, name):
7
self.name = name
8
9
instance = pyblish.api.Instance(name="Car")
10
instance.append(MyCustomChild("wheels"))
11
instance.append(MyCustomChild("engine"))
12
13
MyCustomType = type("MyCustomType", (object,), {})
14
15
owner = MyCustomType()
16
owner.value = "John Doe"
17
make = MyCustomType()
18
make.value = "Ford"
19
20
instance.data["owner"] = owner
21
instance.data["make"] = make
22
instance.data["miles"] = "123"
Copied!
{{ file.mtime }}