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 Wed, 24 May 2017 12:10:57 GMT
Github user mxmrlv commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/133#discussion_r118227037
  
    --- Diff: aria/orchestrator/context/common.py ---
    @@ -194,3 +194,242 @@ def _render_resource(self, resource_content, variables):
             variables.setdefault('ctx', self)
             resource_template = jinja2.Template(resource_content)
             return resource_template.render(variables)
    +
    +    def _teardown_db_resources(self):
    +        self.model.log._session.close()
    +        self.model.log._engine.dispose()
    +
    +
    +class _InstrumentedCollection(object):
    +
    +    def __init__(self,
    +                 model,
    +                 parent,
    +                 field_name=None,
    +                 item_cls=None,
    +                 seq=None,
    +                 is_top_level=True,
    +                 **kwargs):
    +        self._model = model
    +        self._parent = parent
    +        self._field_name = field_name
    +        self._item_cls = item_cls
    +        self._is_top_level = is_top_level
    +        self._load(seq, **kwargs)
    +
    +    @property
    +    def _raw(self):
    +        raise NotImplementedError
    +
    +    def _load(self, seq, **kwargs):
    +        """
    +        Instantiates the object from existing seq.
    +
    +        :param seq: the original sequence to load from
    +        :return:
    +        """
    +        raise NotImplementedError
    +
    +    def _set(self, key, value):
    +        """
    +        set the changes for the current object (not in the db)
    +
    +        :param key:
    +        :param value:
    +        :return:
    +        """
    +        raise NotImplementedError
    +
    +    def _del(self, collection, key):
    +        raise NotImplementedError
    +
    +    def _instrument(self, key, value):
    +        """
    +        Instruments any collection to track changes (and ease of access)
    +        :param key:
    +        :param value:
    +        :return:
    +        """
    +        if isinstance(value, _InstrumentedCollection):
    +            return value
    +        elif isinstance(value, dict):
    +            instrumentation_cls = _InstrumentedDict
    +        elif isinstance(value, list):
    +            instrumentation_cls = _InstrumentedList
    +        else:
    +            return value
    +
    +        return instrumentation_cls(self._model, self, key, self._item_cls, value, False)
    +
    +    def _raw_value(self, value):
    +        """
    +        Get the raw value.
    +        :param value:
    +        :return:
    +        """
    +        if self._is_top_level and isinstance(value, self._item_cls):
    --- End diff --
    
    chnage _item_cls to Parameter


---
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