In the Jam.py framework, two tasks work at the same time: the Application builder and the Project. Each of them represents a tree of objects - there is the Application builder task tree and the Project task tree. Therefore, before considering the Jam.py workflow, you need to familiarize yourself with the concept of the task tree.
The the Jam.py workflow is the following:
When server.py is run it creates WSGI application that, in its own turn, creates the Application builder task tree.
The Project task tree is created on the server by Application builder after the server receives first request from the Project client. To do so, the Application builder uses metadata stored in admin.sqlite database in the root folder of the project. After creating a task tree the server application triggers the on_created event, that can be used to initialize the server task tree.
When an application on the client (Application builder or Project) is first run in the browser (after
index.htmlhave been loaded) the empty task object is built that sends to the server a request to initialize itself.
If the project safe mode parameter is set, the framework checks if a user is logged, before executing any request. If not, then the application on the client creates a login form, and after the user inputs its login and password, the client task sends the server a request to login.
After successful login or if the project safe mode parameter is not set, the server sends the client information about the requested task. The task on the client builds its tree, based on this information, assigns event handlers to its objects and executes on_page_loaded event handler.
In this event handler a developer should attach JQuery event handler functions to HTML elements of the DOM, defined in the
index.htmlfile. In these functions a developer can use methods of items of the task tree to perform some specific tasks. These methods, when executed, trigger different events in which other methods could be called and so on. See Client side programming.
Items of the task tree, that have corresponding database tables, have methods to read and write data in the server database. See Data programming.
The report items generate the reports on the server, based on the LibrOffice templates. See Programming reports.
All the items, whose methods generate a request to the server, do it the following way: they call the method of the task that sends to the server the ID of the task, the ID the item, the type of the request and its parameters. The server on receiving the request, based on passed IDs, finds the task (it can be Project task or Application builder task) and the item on the server, executes the corresponding method with passed parameters and returns the result of the execution to the client. These server methods could trigger their own events that can override the default behavior. See Server side programming