4.1. Generator types
To accommodate different scenarios, OrmFactory supports three types of generators: XML, command-line, and Python script generators. When you create a new generator, you will be given a choice of which generator to add.
Xml generator
The xml generator can be used either to debug an external code generator, or in a chain of generators to prepare a data structure for the following generators. It prepares an xml file of the structure in the same format as the command line generator or python generator receives it.
Its difference is that the generated xml file will not be deleted after the generator call chain is completed.
Command line generator
This is a simple mechanism for calling an external program by passing the name of a temporary file as a parameter. The temporary file contains the project structure in xml format, similar to the xml generator.
This type of generator works with any programming language or internal tool.
Python script generator
This type of generator, like the previous one, also passes the generated project structure as a link to a temporary file. But unlike the previous one, it launches the Python interpreter with your script.
For this mechanism to work, you must have Python installed and the paths specified.
You can use your favorite IDE to create and edit Python scripts. But for quick editing and debugging, OrmFactory has a simple editor built in. While not a full IDE, it functions more like a syntax-highlighted notepad, but it allows you to run a script with one button (F5
) and see debug messages sent by the script via print.
Note: scripts can only be executed from disk, so when you press F5
, the changes are first saved and only then launched.
For more information on how to work with the project structure, see the 4.3. Project structure section.
Example from GitHub
OrmFactory can connect to the public generator repository. The “Example from GitHub” menu shows available generators with descriptions and ORM/DB icons.
When you download a generator, it is added to your project as a regular Python generator (the same type as described in the previous section). There are no automatic updates — once downloaded, the generator is yours to modify. It is recommended to commit it into your own repository and maintain it independently.
The repository is open for contributions: add a Python script under the correct directory and reference it in entity-index.json
or migration-index.json
through a pull request.
For more information, see the article about our examples.