saltstack/salt — pull request #10922 by borgstrom (2014-03-04 03:40:38+00:00)
Title: Refactor and modularize of the loader interface, adding Map to pyobjects

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.