The problem with using the loaded states (see commit cc8539f) is that
you can end up in situations where a particular state doesn't exist for
whatever reason. This prevents you from building states freely (see
ticket #10918).
The refactor focuses on breaking out the `gen_functions` function into a
number of smaller reusable functions so that pyobjects can load all of
the states and still process `__virtual__()` and `__virtualname__` in a
way that makes sense for building states. After all pyobjects is just
compiling a high state data structure, if a state is available or not
during application time is up to the minion.
As part of this refactor I have also updated all of the inline comments
in the loader to be more consistent with the way things are actually
working now (such as `__virtual__()` returning a string being
deprecated).
There are also some pep8 fixes to the loader file.
Fix#10918
----
This also adds a new feature to pyobjects named `Map`, which allows for
definition of grain dependent data in a pythonic way -- using inner
classes.
----
Lastly this ditches the instance based registry and instead uses a class
based approach like a singleton.
As it stands the following will fail as we didn't allow duplicate IDs
under any circumstances:
with Pkg.installed("nginx"):
Service.running("nginx")
This commit changes the way the StateRegistry stores states to allow the
above example to work properly.
Now it behaves much more closely to the YAML + Jinja renderer.
This is another suggestion from @mgwilliams. It adds an object to the
sls file scope named Salt, which dispatches its attributes to the
__salt__ dictionary.
For example, the following two lines are functionally the same:
ret = Salt.cmd.run(bar)
ret = salt['cmd.run'](bar)