You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by mxmrlv <gi...@git.apache.org> on 2016/11/06 16:10:39 UTC

[GitHub] incubator-ariatosca pull request #12: ARIA-3 Create an API for creating work...

Github user mxmrlv commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/12#discussion_r86688529
  
    --- 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
    --- End diff --
    
    insert meaningfull exception


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