Skip to content

Commit 7351eeb

Browse files
authored
Merge pull request #6 from feltech/work/4-bumpOpenAssetIOVersion
[Core] Bump to OpenAssetIO-alpha.14
2 parents dee9b5f + 5771da1 commit 7351eeb

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

plugin/my_asset_manager/MyAssetManagerInterface.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# https://openassetio.github.io/OpenAssetIO/classopenassetio_1_1v1_1_1manager_api_1_1_manager_interface.html#details (pylint: disable=line-too-long)
1313
# As such, any expensive module imports should be deferred.
1414
from openassetio import constants, BatchElementError, TraitsData
15+
from openassetio.access import PolicyAccess, ResolveAccess
1516
from openassetio.managerApi import ManagerInterface
1617
from openassetio_mediacreation.traits.content import LocatableContentTrait
1718
from openassetio_mediacreation.traits.managementPolicy import ManagedTrait
@@ -61,24 +62,24 @@ def info(self):
6162
# to acquire the GIL and enter Python.
6263
return {constants.kInfoKey_EntityReferencesMatchPrefix: self.__reference_prefix}
6364

64-
def managementPolicy(self, traitSets, context, hostSession):
65+
def managementPolicy(self, traitSets, policyAccess, context, hostSession):
6566
# 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 :
7071
# https://github.com/OpenAssetIO/OpenAssetIO-MediaCreation
7172
policies = []
7273
for traitSet in traitSets:
7374
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
7677
# for read, and contain LocatableContent, as we can supply
7778
# data for that trait, we imbue a managed policy response,
7879
# as well as the traits we are able to supply data for. It's
7980
# 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:
8283
ManagedTrait.imbueTo(policy)
8384
LocatableContentTrait.imbueTo(policy)
8485

@@ -102,11 +103,19 @@ def isEntityReferenceString(self, someString, hostSession):
102103
return someString.startswith(self.__reference_prefix)
103104

104105
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,
106114
):
115+
# pylint: disable=too-many-locals
107116
# 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:
110119
result = BatchElementError(
111120
BatchElementError.ErrorCode.kEntityAccessError, "Entities are read-only"
112121
)

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ name = "my_asset_manager"
66
version = "1.0.0"
77
requires-python = ">=3.7"
88
dependencies = [
9-
"openassetio == 1.0.0a13",
10-
"openassetio-mediacreation == 1.0.0a6"
9+
"openassetio == 1.0.0a14",
10+
"openassetio-mediacreation == 1.0.0a7"
1111
]
1212

1313
authors = [

tests/business_logic_suite.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# pylint: disable=invalid-name, missing-function-docstring, missing-class-docstring
1010

11-
from openassetio import Context
11+
from openassetio.access import ResolveAccess
1212
from openassetio.test.manager.harness import FixtureAugmentedTestCase
1313
from openassetio_mediacreation.traits.content import LocatableContentTrait
1414

@@ -34,7 +34,7 @@ def test_when_refs_found_then_success_callback_called_with_expected_values(self)
3434
entity_reference = self._manager.createEntityReference(ref_str)
3535

3636
trait_set = {LocatableContentTrait.kId}
37-
context = self.createTestContext(access=Context.Access.kRead)
37+
context = self.createTestContext()
3838

3939
result = [None]
4040

@@ -47,7 +47,9 @@ def error_cb(idx, batchElementError):
4747
f" {batchElementError.message}"
4848
)
4949

50-
self._manager.resolve([entity_reference], trait_set, context, success_cb, error_cb)
50+
self._manager.resolve(
51+
[entity_reference], trait_set, ResolveAccess.kRead, context, success_cb, error_cb
52+
)
5153

5254
self.assertTrue(len(result) == 1)
5355
# Check all traits are present, and their properties.

0 commit comments

Comments
 (0)