Working spawning from both module and store
This commit is contained in:
parent
43ecca0d41
commit
7af714aa53
1 changed files with 8 additions and 0 deletions
|
|
@ -422,13 +422,19 @@ def validate_prototype(prototype, protkey=None, protparents=None, _visited=None)
|
||||||
protparents = get_protparents()
|
protparents = get_protparents()
|
||||||
if _visited is None:
|
if _visited is None:
|
||||||
_visited = []
|
_visited = []
|
||||||
|
protkey = protkey.lower() if protkey is not None else None
|
||||||
|
|
||||||
assert isinstance(prototype, dict)
|
assert isinstance(prototype, dict)
|
||||||
|
|
||||||
if id(prototype) in _visited:
|
if id(prototype) in _visited:
|
||||||
raise RuntimeError("%s has infinite nesting of prototypes." % protkey or prototype)
|
raise RuntimeError("%s has infinite nesting of prototypes." % protkey or prototype)
|
||||||
|
|
||||||
_visited.append(id(prototype))
|
_visited.append(id(prototype))
|
||||||
protstrings = prototype.get("prototype")
|
protstrings = prototype.get("prototype")
|
||||||
|
|
||||||
if protstrings:
|
if protstrings:
|
||||||
for protstring in make_iter(protstrings):
|
for protstring in make_iter(protstrings):
|
||||||
|
protstring = protstring.lower()
|
||||||
if protkey is not None and protstring == protkey:
|
if protkey is not None and protstring == protkey:
|
||||||
raise RuntimeError("%s tries to prototype itself." % protkey or prototype)
|
raise RuntimeError("%s tries to prototype itself." % protkey or prototype)
|
||||||
protparent = protparents.get(protstring)
|
protparent = protparents.get(protstring)
|
||||||
|
|
@ -546,6 +552,8 @@ def spawn(*prototypes, **kwargs):
|
||||||
# get available protparents
|
# get available protparents
|
||||||
protparents = get_protparents()
|
protparents = get_protparents()
|
||||||
|
|
||||||
|
print("protparents: {}".format(protparents))
|
||||||
|
|
||||||
# overload module's protparents with specifically given protparents
|
# overload module's protparents with specifically given protparents
|
||||||
protparents.update(kwargs.get("prototype_parents", {}))
|
protparents.update(kwargs.get("prototype_parents", {}))
|
||||||
for key, prototype in protparents.items():
|
for key, prototype in protparents.items():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue