openalea/openalea — pull request #94 by gbaty (2014-11-07 15:01:18+00:00)
Title: Clean model rebased

Restructure models and execution.

**Model**

Model is a runnable object with inputs, outputs and runnable code.
Important methods and attributes are:

- Model.inputs_info : attribute defining inputs
- Model.outputs_info : attribute defining outputs

- Model.init : prepare namespace and define initial inputs
- Model.step: run code one time
- Model.run : init + step

- Model.set_func_code : set executable code corresponding to step, init, ...
- Model.set_code : set code containing i/o data in headers, step code and functions

**Data**

Data is an object representing binary raw data. A data has a path and a filename.
If file exists, data content is stored on disk, else data content is stored in memory.
In both case, one can get content thanks to "read" method.
Data is not runnable and can be of any type: source code, image, ...
Currently, only physical path are implemented.

**Conversion services**

Some kind of Data can be converted naturally to model and some Model to data.
For example, it is the case for Python file and PythonModel.

This conversion is done with services
- core.service.model.to_model(data) : convert a model to data
- core.service.data.to_data(model) : convert a data to model

**Run services**

Two service are used to run models:
- core.service.run.namespace() : returns a dict containing control, libs and data loaded when a project is open
- core.service.run.get_model(name) : search a model with name in project, returns a Model class if found

**Graphical Editors**

Editor are Qt widgets able to edit Data object.
OpenAleaLab provides two editors:
- RichTextEditor: source code files : python, lpy, r, ...
- DataflowView : visualea dataflows

**ParadigmEditor**

This widget allow to open, edit and save model and data and also run models.
Widget uses "Graphical editors" to edit data and "to_data" to convert model to data.
It uses "to_model" to convert content to runnable models and be able to run it.
Internally, it uses "ParadigmController" to do that.

**ParadigmController**

ParadigmController is a class that knows which editor to use to edit data and model.
Sometimes, it is possible to run only parts of code. In this case ParadigmController can extract and adapt part of code from editor to run it.
Also, model sometimes need additionnal information to run. For example "colormap" defined in an other widget or "controls".
It is the role of ParadigmController to extract this information and pass it to model.