Merge "Broken owner parameter for getAttr/setAttr was fixed"
This commit is contained in:
@@ -39,6 +39,7 @@ DM_OBJECTS = 'Objects'
|
||||
DM_OBJECTS_COPY = 'ObjectsCopy'
|
||||
DM_ATTRIBUTES = 'Attributes'
|
||||
|
||||
META_MURANO_METHOD = '?muranoMethod'
|
||||
META_NO_TRACE = '?noTrace'
|
||||
|
||||
CORE_LIBRARY = 'io.murano'
|
||||
|
@@ -105,6 +105,8 @@ class MuranoTypeName(yaqltypes.LazyParameterType, yaqltypes.PythonType):
|
||||
value = super(MuranoTypeName, self).convert(
|
||||
value, sender, context, function_spec, engine)
|
||||
if isinstance(value, basestring):
|
||||
if function_spec.meta.get(constants.META_MURANO_METHOD):
|
||||
context = helpers.get_caller_context(context)
|
||||
murano_type = helpers.get_type(context)
|
||||
value = dsl_types.MuranoClassReference(
|
||||
helpers.get_class(
|
||||
|
@@ -45,7 +45,8 @@ class MuranoMethod(dsl_types.MuranoMethod):
|
||||
if isinstance(payload, specs.FunctionDefinition):
|
||||
self._body = payload
|
||||
else:
|
||||
self._body = yaql_integration.get_function_definition(payload)
|
||||
self._body = yaql_integration.get_function_definition(
|
||||
payload, weakref.proxy(self))
|
||||
self._arguments_scheme = None
|
||||
self._usage = (self._body.meta.get('usage') or
|
||||
self._body.meta.get('Usage') or
|
||||
@@ -71,7 +72,8 @@ class MuranoMethod(dsl_types.MuranoMethod):
|
||||
self._arguments_scheme[name] = typespec.ArgumentSpec(
|
||||
self.name, name, record[name], self.murano_class)
|
||||
self._yaql_function_definition = \
|
||||
yaql_integration.build_wrapper_function_definition(self)
|
||||
yaql_integration.build_wrapper_function_definition(
|
||||
weakref.proxy(self))
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
@@ -12,12 +12,15 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from yaql import specs
|
||||
|
||||
from murano.dsl import dsl
|
||||
from murano.dsl import helpers
|
||||
|
||||
|
||||
@dsl.name('io.murano.Object')
|
||||
class SysObject(object):
|
||||
@specs.parameter('owner', dsl.MuranoTypeName(True), nullable=False)
|
||||
def set_attr(self, this, context, name, value, owner=None):
|
||||
if owner is None:
|
||||
owner = helpers.get_type(helpers.get_caller_context(context))
|
||||
@@ -25,6 +28,7 @@ class SysObject(object):
|
||||
attribute_store = helpers.get_attribute_store(context)
|
||||
attribute_store.set(this.object, owner, name, value)
|
||||
|
||||
@specs.parameter('owner', dsl.MuranoTypeName(True), nullable=False)
|
||||
def get_attr(self, this, context, name, default=None, owner=None):
|
||||
if owner is None:
|
||||
owner = helpers.get_type(helpers.get_caller_context(context))
|
||||
|
@@ -136,7 +136,7 @@ def _infer_parameter_type(name, class_name):
|
||||
return _infer_parameter_type(name[3 + len(class_name):], class_name)
|
||||
|
||||
|
||||
def get_function_definition(func):
|
||||
def get_function_definition(func, murano_method):
|
||||
body = func
|
||||
param_type_func = lambda name: _infer_parameter_type(name, None)
|
||||
is_method = False
|
||||
@@ -166,6 +166,7 @@ def get_function_definition(func):
|
||||
return body(*args, **kwargs)
|
||||
|
||||
fd.payload = payload
|
||||
fd.meta[constants.META_MURANO_METHOD] = murano_method
|
||||
return fd
|
||||
|
||||
|
||||
@@ -182,6 +183,7 @@ def _build_native_wrapper_function_definition(murano_method):
|
||||
|
||||
@specs.method
|
||||
@specs.name(murano_method.name)
|
||||
@specs.meta(constants.META_MURANO_METHOD, murano_method)
|
||||
def payload(__context, __sender, *args, **kwargs):
|
||||
executor = helpers.get_executor(__context)
|
||||
args = tuple(dsl.to_mutable(arg, engine) for arg in args)
|
||||
@@ -214,6 +216,7 @@ def _build_mpl_wrapper_function_definition(murano_method):
|
||||
fd.set_parameter(specs.ParameterDefinition(
|
||||
'__sender', yaqltypes.PythonType(dsl_types.MuranoObject, False), 1))
|
||||
|
||||
fd.meta[constants.META_MURANO_METHOD] = murano_method
|
||||
return fd
|
||||
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
---
|
||||
features:
|
||||
- Now all native MuranoPL methods (those that are written in Python)
|
||||
have "?muranoMethod" metadata key referring to MuranoMethod instance for
|
||||
the method.
|
||||
fixes:
|
||||
- It was impossible to explicitly provide attribute owner class to
|
||||
getAttr/setAttr methods without using namespace prefix or if the type was
|
||||
not from the core library.
|
Reference in New Issue
Block a user