======================= Server side programming ======================= In most cases, the client sends a request to the server when following methods of an item are executed: * :doc:`open ` * :doc:`apply ` * :doc:`print ` * :doc:`server ` In these cases the client sends to the server the :doc:`ID ` of the item's task, the :doc:`ID ` of 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. The server method can trigger events that can modify its default behavior. Every item of the task tree have the :doc:`environ ` and :doc:`session ` attributes that store context of the current request. The most common server events are: * :doc:`on_created ` - The event is triggered by the task when it has just been created by the server application. It can be used to initialize the project. * :doc:`on_apply events ` - These events are triggered when the ``apply`` method of the item is called on the :doc:`client ` or the :doc:`server ` * :doc:`on_open_events ` - These events are triggered when the ``open`` method of the item is called on the :doc:`client ` or the :doc:`server ` * :doc:`on_generate ` - "The event is triggered when the :doc:`print ` method of a report is called on the client. .. note:: Note that the task tree on the server is immutable, you can not change the attributes of the items in the task tree. You must use the :doc:`copy ` method to create a copy of an item. This copy is an exact copy of an item at the time of creating of the task tree. It is not added to the :doc:`task tree ` and will be destroyed by Python garbage collector when no longer needed. .. toctree:: :maxdepth: 1 on_apply_events on_open_events