Skip to content

Commit

Permalink
Merge branch 'tickets/DM-31507'
Browse files Browse the repository at this point in the history
  • Loading branch information
natelust committed Aug 26, 2021
2 parents 686b14f + 4492682 commit b83a959
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

from . import ConfigurableAction

import weakref


class ConfigurableActionStructUpdater:
"""This descriptor exists to abstract the logic of using a dictionary to
Expand Down Expand Up @@ -126,7 +128,7 @@ class ConfigurableActionStruct:

def __init__(self, config: Config, field: ConfigurableActionStructField,
value: Mapping[str, ConfigurableAction], at: Any, label: str):
object.__setattr__(self, '_config', config)
object.__setattr__(self, '_config_', weakref.ref(config))
object.__setattr__(self, '_attrs', {})
object.__setattr__(self, '_field', field)
object.__setattr__(self, '_history', [])
Expand All @@ -137,6 +139,13 @@ def __init__(self, config: Config, field: ConfigurableActionStructField,
for k, v in value.items():
setattr(self, k, v)

@property
def _config(self) -> Config:
# Config Fields should never outlive their config class instance
# assert that as such here
assert(self._config_() is not None)
return self._config_()

@property
def history(self) -> List[tuple]:
return self._history
Expand Down

0 comments on commit b83a959

Please sign in to comment.