12
12
# https://openassetio.github.io/OpenAssetIO/classopenassetio_1_1v1_1_1manager_api_1_1_manager_interface.html#details (pylint: disable=line-too-long)
13
13
# As such, any expensive module imports should be deferred.
14
14
from openassetio import constants , BatchElementError , TraitsData
15
+ from openassetio .access import PolicyAccess , ResolveAccess
15
16
from openassetio .managerApi import ManagerInterface
16
17
from openassetio_mediacreation .traits .content import LocatableContentTrait
17
18
from openassetio_mediacreation .traits .managementPolicy import ManagedTrait
@@ -61,24 +62,24 @@ def info(self):
61
62
# to acquire the GIL and enter Python.
62
63
return {constants .kInfoKey_EntityReferencesMatchPrefix : self .__reference_prefix }
63
64
64
- def managementPolicy (self , traitSets , context , hostSession ):
65
+ def managementPolicy (self , traitSets , policyAccess , context , hostSession ):
65
66
# The management policy defines which traits the manager is
66
- # capable of imbuing queried traitSets with. In this case, we
67
- # manage locations of assets only, and only in a read, not a
68
- # write, context. Note `LocatableContentTrait` is a trait from
69
- # the openassetio-mediacreation library, see :
67
+ # capable of imbuing queried traitSets with. In this case, the
68
+ # manager allows read access to the locations of assets.
69
+ # Note `LocatableContentTrait` is a trait
70
+ # from the openassetio-mediacreation library, see :
70
71
# https://github.com/OpenAssetIO/OpenAssetIO-MediaCreation
71
72
policies = []
72
73
for traitSet in traitSets :
73
74
policy = TraitsData ()
74
- # The host asks specifically if a sets of traits are
75
- # supported In this case, if any of the input traitSets are
75
+ # The host asks specifically if sets of traits are
76
+ # supported. In this case, if any of the input traitSets are
76
77
# for read, and contain LocatableContent, as we can supply
77
78
# data for that trait, we imbue a managed policy response,
78
79
# as well as the traits we are able to supply data for. It's
79
80
# important to get this right, for more info, see:
80
- # https://openassetio.github.io/OpenAssetIO/classopenassetio_1_1v1_1_1host_api_1_1_manager .html#acdf7d0c3cef98cce7abaf8fb5f004354
81
- if context . isForRead () and LocatableContentTrait .kId in traitSet :
81
+ # https://openassetio.github.io/OpenAssetIO/classopenassetio_1_1v1_1_1manager_api_1_1_manager_interface .html#ab86b5623a355d04086bae76875ebee17
82
+ if policyAccess == PolicyAccess . kRead and LocatableContentTrait .kId in traitSet :
82
83
ManagedTrait .imbueTo (policy )
83
84
LocatableContentTrait .imbueTo (policy )
84
85
@@ -102,11 +103,19 @@ def isEntityReferenceString(self, someString, hostSession):
102
103
return someString .startswith (self .__reference_prefix )
103
104
104
105
def resolve (
105
- self , entityReferences , traitSet , context , hostSession , successCallback , errorCallback
106
+ self ,
107
+ entityReferences ,
108
+ traitSet ,
109
+ resolveAccess ,
110
+ context ,
111
+ hostSession ,
112
+ successCallback ,
113
+ errorCallback ,
106
114
):
115
+ # pylint: disable=too-many-locals
107
116
# If your resolver doesn't support write, like this one, reject
108
- # a write context via calling the error callback.
109
- if context . isForWrite () :
117
+ # a write access mode via calling the error callback.
118
+ if resolveAccess != ResolveAccess . kRead :
110
119
result = BatchElementError (
111
120
BatchElementError .ErrorCode .kEntityAccessError , "Entities are read-only"
112
121
)
0 commit comments