Commit dd7e8ada by Bach Dániel

common: fix issue #228 (return value of Operation._operation (if any) could be…

common: fix issue #228 (return value of Operation._operation (if any) could be the result of the activity"

closes #228
parent 88946e1a
......@@ -21,7 +21,8 @@ from logging import getLogger
from django.core.exceptions import PermissionDenied, ImproperlyConfigured
from django.utils.translation import ugettext_noop
from .models import activity_context, has_suffix, humanize_exception
from .models import (activity_context, has_suffix, humanize_exception,
logger = getLogger(__name__)
......@@ -110,8 +111,12 @@ class Operation(object):
with activity_context(allargs['activity'], on_abort=self.on_abort,
return self._operation(**arguments)
on_commit=self.on_commit) as act:
retval = self._operation(**arguments)
if (act.result is None and isinstance(
retval, (basestring, int, HumanReadableObject))):
act.result = retval
return retval
def _operation(self, **kwargs):
"""This method is the operation's particular implementation.
......@@ -986,7 +986,7 @@ class RenewOperation(InstanceOperation):
if save: = lease
activity.result = create_readable(ugettext_noop(
return create_readable(ugettext_noop(
"Renewed to suspend at %(suspend)s and destroy at %(delete)s."),
suspend=suspend, delete=delete)
......@@ -1357,7 +1357,7 @@ class ResourcesOperation(InstanceOperation):
activity.result = create_readable(ugettext_noop(
return create_readable(ugettext_noop(
"Priority: %(priority)s, Num cores: %(num_cores)s, "
"Ram size: %(ram_size)s"), priority=priority, num_cores=num_cores,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment