Github user tliron commented on a diff in the pull request:
https://github.com/apache/incubator-ariatosca/pull/188#discussion_r130247244
--- Diff: aria/storage/collection_instrumentation.py ---
@@ -213,32 +235,32 @@ def __init__(self, mapi, *args, **kwargs):
"""
The original model.
- :param wrapped: model to be instrumented
:param mapi: MAPI for the wrapped model
+ :param wrapped: model to be instrumented
+ :param instrumentation: instrumentation dict
+ :param instrumentation_kwargs: arguments for instrumentation class
"""
- super(_InstrumentedModel, self).__init__(*args, **kwargs)
+ super(_InstrumentedModel,
self).__init__(instrumentation_kwargs=dict(mapi=mapi),
+ *args, **kwargs)
self._mapi = mapi
self._apply_instrumentation()
- def __getattr__(self, item):
- return_value = getattr(self._wrapped, item)
- if isinstance(return_value, self._wrapped.__class__):
- return _create_instrumented_model(return_value, self._mapi,
self._instrumentation)
- if isinstance(return_value, (list, dict)):
- return _create_wrapped_model(return_value, self._mapi,
self._instrumentation)
- return return_value
-
def _apply_instrumentation(self):
for field in self._instrumentation:
+ if field.parent.class_ != type(self._wrapped):
--- End diff --
It doesn't seem to break this in tests.
Without this check, the only check is by field name, which caused a lot of
breakage. You would node properties being instrumented for capability
properties. Again, consider the use case of `ctx node capabilities host
properties username`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---