Exemplo n.º 1
0
 def invoke(context, this, *args):
     try:
         executor = helpers.get_executor(context)
         murano_class = helpers.get_type(context)
         return executor.invoke_method(name, this, context, murano_class,
                                       *args)
     except exceptions.NoMethodFound:
         raise yaql.exceptions.YaqlExecutionException()
     except exceptions.AmbiguousMethodName:
         raise yaql.exceptions.YaqlExecutionException()
 def invoke(context, this, *args):
     try:
         executor = helpers.get_executor(context)
         murano_class = helpers.get_type(context)
         return executor.invoke_method(name, this, context,
                                       murano_class, *args)
     except exceptions.NoMethodFound:
         raise yaql.exceptions.YaqlExecutionException()
     except exceptions.AmbiguousMethodName:
         raise yaql.exceptions.YaqlExecutionException()
Exemplo n.º 3
0
    def load(self, value, parent, context, defaults=None):
        #tmp_store = ObjectStore(self._class_loader, self)

        if value is None:
            return None
        if '?' not in value or 'type' not in value['?']:
            raise ValueError()
        system_key = value['?']
        object_id = system_key['id']
        obj_type = system_key['type']
        class_obj = self._class_loader.get_class(obj_type)
        if not class_obj:
            raise ValueError()
        if object_id in self._store:
            obj = self._store[object_id]
        else:
            obj = class_obj.new(parent,
                                self,
                                context=context,
                                object_id=object_id,
                                defaults=defaults)
            self._store[object_id] = obj
            self._designer_attributes_store[object_id] = \
                ObjectStore._get_designer_attributes(system_key)

        argspec = inspect.getargspec(obj.initialize).args
        if '_context' in argspec:
            value['_context'] = context
        if '_parent' in argspec:
            value['_parent'] = parent

        try:
            if parent is None:
                self._initializing = True
            obj.initialize(**value)
            if parent is None:
                self._initializing = False
                obj.initialize(**value)
        finally:
            if parent is None:
                self._initializing = False

        if not self.initializing:
            executor = helpers.get_executor(context)
            methods = obj.type.find_method('initialize')
            for cls, method in methods:
                cls.invoke(method, executor, obj, {})
        return obj
Exemplo n.º 4
0
    def load(self, value, parent, context, defaults=None):
        # tmp_store = ObjectStore(self._class_loader, self)

        if value is None:
            return None
        if "?" not in value or "type" not in value["?"]:
            raise ValueError()
        system_key = value["?"]
        object_id = system_key["id"]
        obj_type = system_key["type"]
        class_obj = self._class_loader.get_class(obj_type)
        if not class_obj:
            raise ValueError()
        if object_id in self._store:
            obj = self._store[object_id]
        else:
            obj = class_obj.new(parent, self, context=context, object_id=object_id, defaults=defaults)
            self._store[object_id] = obj
            self._designer_attributes_store[object_id] = ObjectStore._get_designer_attributes(system_key)

        argspec = inspect.getargspec(obj.initialize).args
        if "_context" in argspec:
            value["_context"] = context
        if "_parent" in argspec:
            value["_parent"] = parent

        try:
            if parent is None:
                self._initializing = True
            obj.initialize(**value)
            if parent is None:
                self._initializing = False
                obj.initialize(**value)
        finally:
            if parent is None:
                self._initializing = False

        if not self.initializing:
            executor = helpers.get_executor(context)
            methods = obj.type.find_method("initialize")
            for cls, method in methods:
                cls.invoke(method, executor, obj, {})
        return obj