This feature is requested by my colleague, and I thought this maybe worth to share.
Example Code
```python
import pyblish.api
import pyblish_qml.api
class CreateInstance(pyblish.api.ContextPlugin):
order = 0
def process(self, context):
instance_names = [
"foo",
"bar",
]
for name in instance_names:
context.create_instance(name)
class OpenComment(pyblish.api.ContextPlugin):
order = 0.1
def process(self, context):
context.data["comment"] = ""
for instance in context:
instance.data["comment"] = ""
class ValidateContextComment(pyblish.api.ContextPlugin):
order = 1
def process(self, context):
if not context.data.get("comment"):
self.log.warning("Context has no comment.")
class ValidateInstanceComment(pyblish.api.InstancePlugin):
order = 1
def process(self, instance):
if not instance.data.get("comment"):
self.log.warning("Instance %r has no comment." % instance.name)
class ComposeComment(pyblish.api.ContextPlugin):
order = 2
def process(self, context):
con_comment = context.data.get("comment", "")
self.log.debug(con_comment)
for instance in context:
int_comment = "%s\n----------\n%s" % (
con_comment,
instance.data.get("comment", "")
)
instance.data["comment"] = int_comment
self.log.info(int_comment)
pyblish.api.deregister_all_plugins()
pyblish.api.deregister_all_paths()
pyblish.api.register_plugin(CreateInstance)
pyblish.api.register_plugin(OpenComment)
pyblish.api.register_plugin(ValidateContextComment)
pyblish.api.register_plugin(ValidateInstanceComment)
pyblish.api.register_plugin(ComposeComment)
pyblish_qml.api.show()
```
Fix
In commit 8240de4ee87bb470b1d718a80de143f849e28d87, fixed the issue that looks like below. The icon of log message is missing at level like Info or Warning.
Hi all, it's been a long time :)
Feature
Commenting on each instance.
This feature is requested by my colleague, and I thought this maybe worth to share.
Example Code
```python import pyblish.api import pyblish_qml.api class CreateInstance(pyblish.api.ContextPlugin): order = 0 def process(self, context): instance_names = [ "foo", "bar", ] for name in instance_names: context.create_instance(name) class OpenComment(pyblish.api.ContextPlugin): order = 0.1 def process(self, context): context.data["comment"] = "" for instance in context: instance.data["comment"] = "" class ValidateContextComment(pyblish.api.ContextPlugin): order = 1 def process(self, context): if not context.data.get("comment"): self.log.warning("Context has no comment.") class ValidateInstanceComment(pyblish.api.InstancePlugin): order = 1 def process(self, instance): if not instance.data.get("comment"): self.log.warning("Instance %r has no comment." % instance.name) class ComposeComment(pyblish.api.ContextPlugin): order = 2 def process(self, context): con_comment = context.data.get("comment", "") self.log.debug(con_comment) for instance in context: int_comment = "%s\n----------\n%s" % ( con_comment, instance.data.get("comment", "") ) instance.data["comment"] = int_comment self.log.info(int_comment) pyblish.api.deregister_all_plugins() pyblish.api.deregister_all_paths() pyblish.api.register_plugin(CreateInstance) pyblish.api.register_plugin(OpenComment) pyblish.api.register_plugin(ValidateContextComment) pyblish.api.register_plugin(ValidateInstanceComment) pyblish.api.register_plugin(ComposeComment) pyblish_qml.api.show() ```Fix
In commit 8240de4ee87bb470b1d718a80de143f849e28d87, fixed the issue that looks like below. The icon of log message is missing at level like
Info
orWarning
.