# The callback that will be registered to onEntityCreate() and will add the # name field to ApiUser Entity objects. # ################################################################################ def addApiUserNameField(sgEntity): ''' This example callback shows how to add user fields to Entity objects as they are created. A SgUserField will be created for all ApiUser Entity objects that adds a name field for the Entity. ApiUsers do not contain a "name" field as part of the Shotgun schema. ''' if sgEntity.type == 'ApiUser': if not sgEntity.hasField('name'): sgEntity.addField(ApiUserNameField()) ################################################################################ # # Register the callback with ShotgunORM onEntityCreate(). # ################################################################################ ShotgunORM.addOnEntityCreate( addApiUserNameField, filterName='ApiUser', description='callback that adds a name field to ApiUser Entity objects' )
# name field to ApiUser Entity objects. # ################################################################################ def addApiUserNameField(sgEntity): ''' This example callback shows how to add user fields to Entity objects as they are created. A SgUserField will be created for all ApiUser Entity objects that adds a name field for the Entity. ApiUsers do not contain a "name" field as part of the Shotgun schema. ''' if sgEntity.type == 'ApiUser': if not sgEntity.hasField('name'): sgEntity.addField(ApiUserNameField()) ################################################################################ # # Register the callback with ShotgunORM onEntityCreate(). # ################################################################################ ShotgunORM.addOnEntityCreate( addApiUserNameField, filterName='ApiUser', description='callback that adds a name field to ApiUser Entity objects')