ariatosca-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxmrlv <...@git.apache.org>
Subject [GitHub] incubator-ariatosca pull request #133: Convert runtime_properties to attribu...
Date Thu, 25 May 2017 15:20:13 GMT
Github user mxmrlv commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/133#discussion_r118509708
  
    --- Diff: aria/orchestrator/context/common.py ---
    @@ -381,33 +381,41 @@ def _raw(self):
             return list(self)
     
     
    -class InstrumentCollection(object):
    +class _InstrumentedModel(object):
     
    -    def __init__(self, field_name):
    -        super(InstrumentCollection, self).__init__()
    +    def __init__(self, field_name, original_model, model_storage):
    +        super(_InstrumentedModel, self).__init__()
             self._field_name = field_name
    -        self._actor = None
    -
    -    @property
    -    def actor(self):
    -        return self._actor
    +        self._model_storage = model_storage
    +        self._original_model = original_model
    +        self._apply_instrumentation()
     
         def __getattr__(self, item):
    -        return getattr(self._actor, item)
    -
    -    def __call__(self, func, *args, **kwargs):
    -        def _wrapper(func_self, *args, **kwargs):
    -            self._actor = func(func_self, *args, **kwargs)
    -            field = getattr(self._actor, self._field_name)
    -
    -            # Preserve the original value. e.g. original attributes would be located
under
    -            # _attributes
    -            setattr(self, '_{0}'.format(self._field_name), field)
    -
    -            # set instrumented value
    -            setattr(self, self._field_name, _InstrumentedDict(func_self.model,
    -                                                              self._actor,
    -                                                              self._field_name,
    -                                                              field))
    -            return self
    -        return _wrapper
    +        return getattr(self._original_model, item)
    +
    +    def _apply_instrumentation(self):
    +
    +        field = getattr(self._original_model, self._field_name)
    +
    +        # Preserve the original value. e.g. original attributes would be located under
    +        # _attributes
    +        setattr(self, '_{0}'.format(self._field_name), field)
    +
    +        # set instrumented value
    +        setattr(self, self._field_name, _InstrumentedDict(self._model_storage,
    +                                                          self._original_model,
    +                                                          self._field_name,
    +                                                          field))
    +
    +
    +def instrument_collection(field_name, func=None):
    --- End diff --
    
    move new classes to parameter_collection_instrumentation.py


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message