The first option you have is to generate the whole python package
AuthorBooks
and its modules Writer.py
and Book.py
.
For that purpose, you'll use the script mdl_generate_python_code.py (note that the same functionalities are also offered in the ZModeler).
On the command-line, type:
mdl_generate_python_code.py model_AuthorBooks.xml
We'll see in the next paragraph that there exists two different way of generating the code. That one is the simplest and uses the default option of the script mdl_generate_python_code.py: -C or --compact-generation-scheme3.1.
The script creates the python package AuthorBooks
in the current
directory, in which you'll find the following files:
AuthorBooks/ |-- Book.py |-- Writer.py |-- __init__.py |-- * model_AuthorBooks.py |-- * model_AuthorBooks.xml `-- setup.py
Note: the files marked with a star (*
) are the only one that are
overwritten by the script, if they already exist.
Also note: even if you generate the python module from a pymodel, you'll only get those two xml-models in the generated package. This might change in the future, in the meantime, feel free to replace them with your pymodel, the code generated in __init__.py loading the model is capable of finding either a pymodel or an xml-model (see Model.searchModel()
This bunch of files gives a minimalist view of what is needed to bind python code to a model and to the framework -this subject is fully discussed in the dedicated section 3.2. You can use it: