def new(self, owner, object_store, **kwargs): obj = murano_object.MuranoObject(self, owner, object_store, **kwargs) def initializer(__context, **params): if __context is None: __context = object_store.executor.create_object_context(obj) init_context = __context.create_child_context() init_context[constants.CTX_ALLOW_PROPERTY_WRITES] = True obj.initialize(init_context, object_store, params) return obj initializer.object = obj return initializer
def load(self, value, owner, default_type=None, scope_type=None, context=None, **kwargs): parsed = helpers.parse_object_definition(value, scope_type, context) if not parsed: raise ValueError('Invalid object representation format') if owner is self._root_owner: self._initializing = True class_obj = parsed['type'] or default_type if not class_obj: raise ValueError( 'Invalid object representation: ' 'no type information was provided') if isinstance(class_obj, dsl_types.MuranoTypeReference): class_obj = class_obj.type object_id = parsed['id'] obj = None if object_id is None else self._store.get(object_id) if not obj: obj = murano_object.MuranoObject( class_obj, helpers.weak_proxy(owner), name=parsed['name'], object_id=object_id if self._keep_ids else None) self.put(obj, object_id or obj.object_id) system_value = ObjectStore._get_designer_attributes( parsed['extra']) self._designer_attributes_store[object_id] = system_value if context is None: context = self.executor.create_object_context(obj) def run_initialize(): self._initializers.extend( obj.initialize(context, parsed['properties'])) run_initialize() if owner is self._root_owner: self._initializing = False run_initialize() if owner is self._root_owner: with helpers.with_object_store(self.parent_store): for fn in self._initializers: fn() return obj