Merge "Namespace resolution error was fixed"
This commit is contained in:
commit
4f6ccd5b3b
@ -71,7 +71,7 @@ class MuranoClassLoader(object):
|
|||||||
|
|
||||||
properties = data.get('Properties') or {}
|
properties = data.get('Properties') or {}
|
||||||
for property_name, property_spec in properties.iteritems():
|
for property_name, property_spec in properties.iteritems():
|
||||||
spec = typespec.PropertySpec(property_spec)
|
spec = typespec.PropertySpec(property_spec, type_obj)
|
||||||
type_obj.add_property(property_name, spec)
|
type_obj.add_property(property_name, spec)
|
||||||
|
|
||||||
methods = data.get('Methods') or data.get('Workflow') or {}
|
methods = data.get('Methods') or data.get('Workflow') or {}
|
||||||
|
@ -68,7 +68,7 @@ class MuranoMethod(dsl_types.MuranoMethod):
|
|||||||
raise ValueError()
|
raise ValueError()
|
||||||
name = record.keys()[0]
|
name = record.keys()[0]
|
||||||
self._arguments_scheme[name] = typespec.ArgumentSpec(
|
self._arguments_scheme[name] = typespec.ArgumentSpec(
|
||||||
record[name])
|
record[name], self.murano_class)
|
||||||
self._yaql_function_definition = \
|
self._yaql_function_definition = \
|
||||||
yaql_integration.build_wrapper_function_definition(self)
|
yaql_integration.build_wrapper_function_definition(self)
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class MuranoObject(dsl_types.MuranoObject):
|
|||||||
name=None, known_classes=None, defaults=None, this=None):
|
name=None, known_classes=None, defaults=None, this=None):
|
||||||
if known_classes is None:
|
if known_classes is None:
|
||||||
known_classes = {}
|
known_classes = {}
|
||||||
self.__owner = owner
|
self.__owner = owner.real_this if owner else None
|
||||||
self.__object_id = object_id or helpers.generate_id()
|
self.__object_id = object_id or helpers.generate_id()
|
||||||
self.__type = murano_class
|
self.__type = murano_class
|
||||||
self.__properties = {}
|
self.__properties = {}
|
||||||
@ -222,7 +222,7 @@ class MuranoObject(dsl_types.MuranoObject):
|
|||||||
|
|
||||||
obj = self.cast(mc)
|
obj = self.cast(mc)
|
||||||
values_to_assign.append((obj, spec.validate(
|
values_to_assign.append((obj, spec.validate(
|
||||||
value, context or self.context, self.real_this,
|
value, self.real_this,
|
||||||
self.real_this, default=default)))
|
self.real_this, default=default)))
|
||||||
for obj, value in values_to_assign:
|
for obj, value in values_to_assign:
|
||||||
obj.__properties[name] = value
|
obj.__properties[name] = value
|
||||||
@ -240,7 +240,7 @@ class MuranoObject(dsl_types.MuranoObject):
|
|||||||
return parent.cast(type)
|
return parent.cast(type)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
continue
|
continue
|
||||||
raise TypeError('Cannot cast')
|
raise TypeError('Cannot cast {0} to {1}'.format(self, type))
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<{0} {1} ({2})>'.format(
|
return '<{0} {1} ({2})>'.format(
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import weakref
|
||||||
|
|
||||||
from murano.dsl import exceptions
|
from murano.dsl import exceptions
|
||||||
from murano.dsl import type_scheme
|
from murano.dsl import type_scheme
|
||||||
|
|
||||||
@ -28,7 +30,8 @@ class PropertyUsages(object):
|
|||||||
|
|
||||||
|
|
||||||
class Spec(object):
|
class Spec(object):
|
||||||
def __init__(self, declaration):
|
def __init__(self, declaration, container_class):
|
||||||
|
self._container_class = weakref.ref(container_class)
|
||||||
self._contract = type_scheme.TypeScheme(declaration['Contract'])
|
self._contract = type_scheme.TypeScheme(declaration['Contract'])
|
||||||
self._usage = declaration.get('Usage') or 'In'
|
self._usage = declaration.get('Usage') or 'In'
|
||||||
self._default = declaration.get('Default')
|
self._default = declaration.get('Default')
|
||||||
@ -38,10 +41,12 @@ class Spec(object):
|
|||||||
'Unknown type {0}. Must be one of ({1})'.format(
|
'Unknown type {0}. Must be one of ({1})'.format(
|
||||||
self._usage, ', '.join(PropertyUsages.All)))
|
self._usage, ', '.join(PropertyUsages.All)))
|
||||||
|
|
||||||
def validate(self, value, context, this, owner, default=None):
|
def validate(self, value, this, owner, default=None):
|
||||||
if default is None:
|
if default is None:
|
||||||
default = self.default
|
default = self.default
|
||||||
return self._contract(value, context, this, owner, default)
|
return self._contract(
|
||||||
|
value, this.cast(self._container_class()).context,
|
||||||
|
this, owner, default)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def default(self):
|
def default(self):
|
||||||
|
@ -61,7 +61,7 @@ class ContractedValue(yaqltypes.GenericType):
|
|||||||
True, None,
|
True, None,
|
||||||
lambda value, sender, context, *args, **kwargs:
|
lambda value, sender, context, *args, **kwargs:
|
||||||
self._value_spec.validate(
|
self._value_spec.validate(
|
||||||
value, sender.context, helpers.get_this(context),
|
value, sender.real_this,
|
||||||
context[constants.CTX_ARGUMENT_OWNER]))
|
context[constants.CTX_ARGUMENT_OWNER]))
|
||||||
|
|
||||||
def convert(self, value, *args, **kwargs):
|
def convert(self, value, *args, **kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user