========
Workflow
========

In the Jam.py framework on the server there are two tasks at the same time: 
Administrator and Project. Each of which represents a tree of objects - there 
are the Administrator task tree and the Project task tree. So prior to 
consideration of the Jam.py workflow it's necessary to be familiar with the 
concept of the :doc:`task tree <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 Administrator task tree.
* The Project task tree is created on the server by Administrator after the 
  server receives first request from the Project client. To do so, the 
  Administrator uses metadata stored in admin.sqlite database in the root folder
  of the project.
* When an application on the client (Administrator or Project) is first run in 
  the browser (after admin.html or index.html have been loaded) the empty task 
  object is built that sends to the server a request to initialize itself.
* If the project 
  :doc:`safe mode </admin/project/parameters>`
  parameter is set, the framework checks if a user is logged, before executing 
  any request. If not, then it notifies the user that it must to login, 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 successfull login or if the project
  :doc:`safe mode </admin/project/parameters>`
  parameter is not set, the server sends the client iformation about the 
  requested task. The task on the client builds its tree, based on this 
  information, assigns event handlers to its objects and executes 
  :doc:`on_page_loaded </refs/client/task/on_page_loaded>`
  event handler. 
* In this event handler a developer should use DOM elements defined in the 
  *index.html* file to 
  :doc:`Forms <interface/forms>`
  
