YunoHost/moulinette — pull request #102 by jeromelebleu (2014-03-26 15:41:06+00:00)
Title: Refactor the moulinette core

At least! Refactor the moulinette in order to separate the core (i.e. *moulinette*) from the YunoHost related operations and to unify interfaces too.

#### Some of the main changes are:

* __Add an *ActionsMap* class:__ it's one of the core classes of the moulinette which allows to construct a parser for one or more actions map namespaces and then process one of its defined action. Extra parameters and actions map parser have been standardized too and it's managed by the *ActionsMap* instance.

* __Standardize interfaces:__ each interfaces are located in `moulinette/interfaces/.py` and must implement *ActionsMapParser* (derived from *BaseActionsMapParser*) and Interface (derived from *BaseInterface*) classes. The method `init_interface` or easy access `cli` and `api` allow to easily create a relevant *ActionsMap* instance and instantiate a new *Interface* object.

* __Define and standardize authenticators:__ authentication for an action is now done in the core through the *ActionsMap* instance and by using the proper authenticator. Each authenticators are located in `moulinette/authenticators/.py` and must implement *Authenticator* class (derived from *BaseAuthenticator*).

* __Review actions map definition:__ some small changes aside, a configuration mechanism has been added with the goal of supporting authentication and other new features. It mainly consists on adding a `_global` root structure which can contain an `arguments` structure - the past `global_arguments` - and a `configuration` structure - which can also be set for an action.

#### Regarding current features, it provides:

* Authentication in the API is done with a session cookie - which is set on log in via the route `/login` and deleted via the route `/logout`
* The Web server which serves the API is started inside the moulinette - by the interface *api* precisely
* The authenticator instance - if needed - is passed to the action method via the first positional argument `auth` (i.e. no need to take care anymore of authentication inside action method)
* *YunoHostError* is replaced by *MoulinetteError* and error code should be one from `errno` module (but it should be reviewed to provide more error code)
* It supports namespaces which allow to define several actions map and choose which one to use
* ...

For a functional example, please have a look at the *test* namespace.

#### What need to be done:
- [ ] Review YunoHost's actions map and all its modules to make them compatible with these changes
- [ ] Move YunoHost library into a new repository (e.g. moulinette-yunohost) and clean up the moulinette
- [ ] Define a `setup.py` to support installation, i18n and python packaging (for a future integration in PyPi)
- [ ] Add some documentation on moulinette core parts and usage
- [ ] Make intensive tests!
- [ ] Release it! :)