8.2.11. The build phase of a webpageΒΆ

Last page update: September 22, 2015

In the construction of the pages, first GenroPy loads the browser (client) with its Javascript engine (the Genro engine). Then the javascript engine immediately requests the server to build the recipe for the DOM. This recipe is returned to the client in a Bag. This is the page description and content of the original datastore form of bags. At this point, the JS can make calls to the python code to further buildings on the page.

In practice, GenroPy behaves in this way:

  1. The client makes the HTTP request page foo through WSGI site:

    client ----------- HTTP ----------> server (wsgisite)
    
  2. GenroPy sends a standard blank page, which contains practically only the engine gnrjs:

    client <----- javascript engine --- server (wsgisite)
    
  3. The JavaScript engine calls the server page content, that is a server side Python function called the main of WebPage

    js engine ------- ready ----------> server
    
  4. The server sends a description of the page content in high level in terms of widgets, and content of the datastore in the form of bags:

    page js <-------- bags ------------ page python
    
  5. From then on, the communication proceeds primarily doing updates to the datastore (or user interface) using the functions rpc:

    page js <- dataRpc() or remote() -> page python
    

Genro creates a Bag using genropy syntax and this Bag is sent as XML to the client. In the client the webpage elements will be stored in the struct bag (??? find a name for the struct Bag!), while data elements will be placed in the datastore

When the XML arrives and the two bags are created a builder is started that will use the struct bag to create html and dojo elements. The builder will also ‘link’ data bag with the related widgets using the ‘^’ syntax [1].

Data bag is really dynamic and you can work on data basically in three ways:

  • data that are passed in the first call (main)
  • data that are entered from the user
  • data that are exchanged with server using rpc commands

Another ways to work on data are:

  • user data entries
  • javascript (client) scripts
  • python (server) scripts

In Genro, to use a script you have to use data and controllers:

For an introduction to the controllers, please check introduction

Footnotes:

[1]For more information on the circumflex accent, please check datastore syntax.