ariatosca-dev 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 #12: ARIA-3 Create an API for creating work...
Date Sun, 06 Nov 2016 16:10:39 GMT
Github user mxmrlv commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/12#discussion_r86688646
  
    --- Diff: aria/context/workflow.py ---
    @@ -164,48 +142,48 @@ def get_blueprint_resource_data(self, path=None):
             return self.resource.blueprint.data(entry_id=self.blueprint_id, path=path)
     
     
    -class OperationContext(LoggerMixin):
    +class _CurrentContext(threading.local):
         """
    -    Context object used during operation creation and execution
    +    Provides thread-level context, which sugarcoats the task api.
         """
     
    -    def __init__(
    -            self,
    -            name,
    -            operation_details,
    -            workflow_context,
    -            node_instance,
    -            inputs=None):
    -        super(OperationContext, self).__init__()
    -        self.name = name
    -        self.id = str(uuid4())
    -        self.operation_details = operation_details
    -        self.workflow_context = workflow_context
    -        self.node_instance = node_instance
    -        self.inputs = inputs or {}
    -
    -    def __repr__(self):
    -        details = ', '.join(
    -            '{0}={1}'.format(key, value)
    -            for key, value in self.operation_details.items())
    -        return '{name}({0})'.format(details, name=self.name)
    +    def _set(self, value):
    +        setattr(self, '_workflow_context', value)
     
    -    def __getattr__(self, attr):
    +    def get(self):
    +        """
    +        Retrieves the current workflow context
    +        :return: the workflow context
    +        :rtype: WorkflowContext
    +        """
             try:
    -            return getattr(self.workflow_context, attr)
    +            return getattr(self, '_workflow_context')
             except AttributeError:
    -            return super(OperationContext, self).__getattribute__(attr)
    +            return None
     
    -    @property
    -    def operation(self):
    +    def clear(self):
             """
    -        The model operation
    +        Clears the current context
             """
    -        return self.model.operation.get(self.id)
    +        if hasattr(self, '_workflow_context'):
    +            delattr(self, '_workflow_context')
     
    -    @operation.setter
    -    def operation(self, value):
    +    @contextmanager
    +    def push(self, workflow_context):
             """
    -        Store the operation in the model storage
    +        Switches the current context to the provides context
    --- End diff --
    
    provides -> provided


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