# HG changeset patch # User jbe # Date 1503286828 -7200 # Node ID 74463f7af12309a0876e71101ab62ee37a3735bf # Parent 8579adac1cc6016991a440e09f2be8013c8e7a17 Further improvements to WebMCP's documentation including instructions for demo application diff -r 8579adac1cc6 -r 74463f7af123 doc/autodoc-header.htmlpart --- a/doc/autodoc-header.htmlpart Mon Aug 21 05:40:09 2017 +0200 +++ b/doc/autodoc-header.htmlpart Mon Aug 21 05:40:28 2017 +0200 @@ -124,7 +124,7 @@

- Filters and initializers are created by adding files in the application's directory structure. The filename determins the execution order of otherwise equally ranked initializers and/or filters. It is a common idiom to start the filename of a filter or initializer with a two digit number to be easily able to change the execution order when desired. Filters and initializers are executed both before and after a request. Each file must contain a command execute.inner(). The part before that command is executed before the request, and the part after that command is executed after the request. + Filters and initializers are created by adding files in the application's directory structure. The filename determins the execution order of otherwise equally ranked initializers and/or filters. It is a common idiom to start the filename of a filter or initializer with a two digit number to be easily able to change the execution order when desired. Filters and initializers are executed both before and after a request. Each file must contain an execute.inner() command. The part before that command is executed before the request, and the part after that command is executed after the request.

The Moonbridge server creates forks (i.e. clones) of the application server process (i.e. the whole Lua engine including all libraries and variables) in order to handle concurrent requests. Certain initializations may be performed before forking, other initializations must be performed after forking. For this purpose, WebMCP allows an application to provide so-called "pre-fork" and "post-fork" initializers. The application's configuration files as well as its pre-fork initializers are executed before forking. The application's post-fork initializers are executed after forking. In particular, any libraries that open file or network handles during initialization must not be loaded before the server process is forked. Opening database connections must be performed after forking as well. WebMCP follows the following execution order (directory structure is explained further down): @@ -252,7 +252,7 @@

Models

- The models in MVA are like the models in MVC; they are used to access data, which is stored in a relational database (PostgreSQL), in an object oriented way. Methods provided by the corresponding classes be used to alter stored objects or execute any other associated program code. Models are usually defined in a file with a lowercase filename ending with ".lua" in the models/ directory of the application. The corresponding model name (i.e. class name) must be written in CamelCase, e.g. "models/my_model.lua" should define a model class named "MyModel". The simplest model is created by calling mondelefant.new_class() and subsequently setting the table attribute of the returned class. + The models in MVA are like the models in MVC; they are used to access data, which is stored in a relational database (PostgreSQL), in an object oriented way. Methods provided by the corresponding classes can be used to alter stored objects or execute any other associated program code. Models are usually defined in a file with a lowercase filename ending with ".lua" in the models/ directory of the application. The corresponding model name (i.e. class name) must be written in CamelCase, e.g. "models/my_model.lua" should define a model class named "MyModel". The simplest model is created by calling mondelefant.new_class() and subsequently setting the table attribute of the returned class.

 -- filename: model/customer_receipt.lua
@@ -263,7 +263,7 @@
     

Views

- The views in the MVA concept are different from the views in the MVC concept. As WebMCP has no controllers, the views are responsible for processing the GET/POST parameters from the webbrowser, fetching the data to be displayed, and creating the output by directly writing HTML to slots of a layout (see slot.select(...), slot.put(...), and slot.put_into(...) or by calling helper functions for the user interface (those functions beginning with "ui."). Views are stored in files with the file path "app/application_name/module_name/view_name.lua". When their corresponding URL, e.g. "http://hostname:port/module_name/view_name.html", is requested, the code in that file gets executed (after calling appropriate filters). After the execution of the view has finished (and after all filters have finished their execution too), the slot data will be inserted into placeholder sections in the selected layout file. The layout file defaults to app/application_name/_layout/default.html" but may be changed using the slot.set_layout(...) function. + The views in the MVA concept are different from the views in the MVC concept. As WebMCP has no controllers, the views are responsible for processing the GET/POST parameters from the webbrowser, fetching the data to be displayed, and creating the output by directly writing HTML to slots of a layout (see slot.select(...), slot.put(...), and slot.put_into(...) or by calling helper functions for the user interface (those functions beginning with "ui."). Views are stored in files with the file path "app/application_name/module_name/view_name.lua". When their corresponding URL, e.g. "http://hostname:port/module_name/view_name.html", is requested, the code in that file gets executed (after calling appropriate filters). After the execution of the view has finished (and after all filters have finished their execution too), the slot data will be inserted into placeholder sections in the selected layout file. The layout file defaults to "app/application_name/_layout/default.html" but may be changed using the slot.set_layout(...) function.

Actions

@@ -305,7 +305,9 @@ Such translation files can be automatically created with the langtool.lua program, found in the framework's bin/ directory.

Directory structure of a WebMCP application

- Summarizing information from the previous section, we get the following directory structure for a WebMCP application: +

+ Summarizing information from the previous section, we get the following directory structure for a WebMCP application: +

Starting your application

- Ensure that the moonbridge binary is within your system's search path and that the moonbridge_http.lua file is included in the LUA_PATH or linked into the framework's lib/ directory (alternatively the MOONBR_LUA_PATH option might be set accordingly at compile-time of the Moonbridge Network Server). To start an application, call the mcp.lua executable (found in framework/bin/mcp.lua) with the following arguments: + Ensure that the moonbridge binary is within your system's search path and that the moonbridge_http.lua file is included in the LUA_PATH or linked into the framework's lib/ directory (alternatively the MOONBR_LUA_PATH option might be set accordingly at compile-time of the Moonbridge Network Server). To start an application, call the mcp.lua executable (found in framework/bin/mcp.lua) with the following four arguments: +

+
    +
  1. Path of the WebMCP framework directory, e.g. ./framework
  2. +
  3. Path of your application's directory, e.g. ./demo-app
  4. +
  5. Name of your applicaiton (usually main)
  6. +
  7. Name of configuration (e.g. devel to use config/devel.lua)
  8. +
+

+ Alternatively, the moonbridge binary may be called directly with the following five arguments:

    -
  1. - Path of the WebMCP framework directory, e.g. ./framework -
  2. -
  3. - Path of your application's directory, e.g. ./demo-app -
  4. -
  5. - Name of your applicaiton (usually main) -
  6. -
  7. - Name of configuration (e.g. devel to use config/devel.lua) -
  8. +
  9. Path to mcp.lua, e.g. ./framework/bin/mcp.lua
  10. +
  11. Path of the WebMCP framework directory, e.g. ./framework
  12. +
  13. Path of your application's directory, e.g. ./demo-app
  14. +
  15. Name of your applicaiton (usually main)
  16. +
  17. Name of configuration (e.g. devel to use config/devel.lua)
+

+ Note that the demo application will require a database to be set up prior to starting. Execute the following shell commands first: +

+
+createdb webmcp_demo
+psql -v ON_ERROR_STOP=1 -f demo-app/db/schema.sql webmcp_demo

Automatically generated reference for the WebMCP environment