Merge "Automatically call MuranoPL initialize/destroy methods"
This commit is contained in:
commit
894f4595cc
@ -4,3 +4,4 @@ Name: Object
|
||||
|
||||
Methods:
|
||||
initialize:
|
||||
destroy:
|
||||
|
@ -83,6 +83,12 @@ class MuranoDslExecutor(object):
|
||||
raise Exception('{0} is not an action'.format(method.name))
|
||||
# TODO (slagun): check method accessibility from murano_class
|
||||
|
||||
if not external_call and is_special_method:
|
||||
LOG.deprecated('initialize/destroy methods are called '
|
||||
'automatically by engine. This call is no-op '
|
||||
'and will become exception in the future')
|
||||
return None
|
||||
|
||||
# restore this from upcast object (no change if there was no upcast)
|
||||
this = this.real_this
|
||||
arguments_scheme = method.arguments_scheme
|
||||
|
@ -130,14 +130,16 @@ class MuranoClass(object):
|
||||
return result[0]
|
||||
|
||||
def find_all_methods(self, name):
|
||||
#resolved_name = self._namespace_resolver.resolve_name(name, self.name)
|
||||
if name in self._methods:
|
||||
return [self.methods[name]]
|
||||
if not self._parents:
|
||||
return []
|
||||
return list(reduce(
|
||||
lambda x, y: x + [t for t in y if t not in x],
|
||||
[p.find_all_methods(name) for p in self._parents]))
|
||||
result = []
|
||||
queue = collections.deque([self])
|
||||
while queue:
|
||||
c = queue.popleft()
|
||||
if name in c.methods:
|
||||
method = c.methods[name]
|
||||
if method not in result:
|
||||
result.append(method)
|
||||
queue.extend(c.parents)
|
||||
return result
|
||||
|
||||
def find_property(self, name):
|
||||
types = collections.deque([self])
|
||||
|
@ -109,7 +109,8 @@ class MuranoMethod(object):
|
||||
return macros.MethodBlock(body)
|
||||
|
||||
def __repr__(self):
|
||||
return 'MuranoMethod({0})'.format(self.name)
|
||||
return 'MuranoMethod({0}::{1})'.format(
|
||||
self.murano_class.name, self.name)
|
||||
|
||||
def invoke(self, executor, this, parameters):
|
||||
return self.murano_class.invoke(self.name, executor, this, parameters)
|
||||
|
@ -88,6 +88,7 @@ class ObjectStore(object):
|
||||
if not self.initializing:
|
||||
executor = helpers.get_executor(context)
|
||||
methods = obj.type.find_all_methods('initialize')
|
||||
methods.reverse()
|
||||
for method in methods:
|
||||
method.invoke(executor, obj, {})
|
||||
return obj
|
||||
|
Loading…
Reference in New Issue
Block a user