Skip to content

Commit

Permalink
[Core] Remove custom locale
Browse files Browse the repository at this point in the history
There were two issues with the existing use of the locale:

- It doesn't map to batching (as we have one locale per-call), so might
  encourage a dependency on context-specific data that then traps a host
  into single entity resolves.

- The specification used on-the-stack classes which isn't in the spirit
  of using TraitGen to ensure that the definition is readily available
  to a manager's code base.

As such, remove for now.

Part of OpenAssetIO#16

Signed-off-by: Tom Cowland <[email protected]>
  • Loading branch information
foundrytom committed May 9, 2023
1 parent 7f98cd7 commit b1f8422
Showing 1 changed file with 3 additions and 27 deletions.
30 changes: 3 additions & 27 deletions otio_openassetio/operations/openassetio_media_linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@

from collections import namedtuple

from openassetio import log, exceptions, SpecificationBase
from openassetio import log, exceptions
from openassetio.hostApi import HostInterface, ManagerFactory
from openassetio.pluginSystem import PythonPluginSystemManagerImplementationFactory


import openassetio_mediacreation
from openassetio_mediacreation.traits.timeline import ClipTrait
from openassetio_mediacreation.traits.content import LocatableContentTrait

import opentimelineio as otio
Expand Down Expand Up @@ -49,11 +46,6 @@ def link_media_reference(in_clip, media_linker_argument_map):
if not entity_reference:
return

# Update the locale with more information about this call
# This is perhaps more illustrative than useful at this point.
context = session_state.context
ClipTrait(context.locale).setName(in_clip.name)

# In this simple implementation, we only need the URL to the media,
# so we use the LocatableContentTrait directly. As we don't know the
# specifics of what the external reference may point to, using any
Expand All @@ -62,7 +54,7 @@ def link_media_reference(in_clip, media_linker_argument_map):
# manager fetching any data we are not going to use.
try:
entity_data = manager.resolve(
entity_reference, {LocatableContentTrait.kId}, context
entity_reference, {LocatableContentTrait.kId}, session_state.context
)
mr.target_url = LocatableContentTrait(entity_data).getLocation()
except Exception as exc:
Expand Down Expand Up @@ -98,20 +90,6 @@ def displayName(self):
return "OpenTimelineIO OpenAssetIO Media Linker plugin"


class OTIOClipLocale(SpecificationBase):
"""
An OpenAssetIO Locale that represents API calls for a track clip
"""

kTraitSet = {
# Describe where we are in the OTIO structure a little
openassetio_mediacreation.traits.timeline.TimelineTrait.kId,
openassetio_mediacreation.traits.timeline.TrackTrait.kId,
openassetio_mediacreation.traits.timeline.ClipTrait.kId,
"otio",
}


#
# Session Management
#
Expand Down Expand Up @@ -152,8 +130,7 @@ def _sessionState(args: dict) -> SessionState:
def _createSessionState(args: dict) -> SessionState:
"""
Configures a new SessionState with the manager + settings from the
supplied args. A new Context is created and configured for read
with the correct locale.
supplied args. A new Context is created and configured for read.
If no identifier is provided in the settings, then the OpenAssetIO
default manager config mechanism will be used as a fallback.
Expand All @@ -179,6 +156,5 @@ def _createSessionState(args: dict) -> SessionState:
# now though and is better than making a context per clip.
context = manager.createContext()
context.access = context.Access.kRead
context.locale = OTIOClipLocale.create().traitsData()

return SessionState(manager=manager, context=context)

0 comments on commit b1f8422

Please sign in to comment.