The process can be hard to follow because many signals get called.
The following is an attempt in helping you (developers) find your way better in the Snap! environment.
-
snap.cgi gets called by Apache
-
snap.cgi connects to snapserver
-
snap.cgi sends the Apache parameters to snapserver
-
snapserver creates a snap_child object
-
snap_child verifies the data sent by snap.cgi
-
snap_child loads the plugins
-
snap_child calls the execute() signal
-
path plugin responds by checking that the path is valid:
-
Page is in Cassandra: get the path::primary_owner as the plugin to handle the page
-
Page is NOT in Cassandra: send the can_handle_dynamic_path() signal to see whether a module can handle that page (i.e. see char_chart for a simple example of dynamic paths.)
-
If the page is not owned by a plugin, generate a 404 immediately
-
Page is own, verify that the current user has permission with the snap_child::verify_permissions() function and the validate_action() signal
-
Permission plugin receives the validate_action() signal
-
Permission plugin sends the access_allowed() signal (through the server) to signal all the plugins and let them decide whether the page is accessible
-
Permission plugin implements the signal as void permissions::on_access_allowed() and that implementation checks the default permissions; other plugins are expected to forbid access to a page based on other criteria; for example the login page is not accessible to a user until the user logs out
-
path plugin calls on_path_execute() on the plugin that owns that page
-
(by default, assuming that page is owned by "content") content::on_path_execute() is called and produces the HTML output by calling the layout apply_layout() function
-
layout generates an internal (all in memory) XML document that will include all the data used to generate the page
-
the layout then give all plugins a chance to tweak the XML header metadata with the generate_header_content() signal
-
at this point the owner plugin calls on_generate_main_content()
-
(plugin dependent) the plugin generates the body of the page (and eventually changes other parameters such as the title if it is expected to generate a dynamic title); this is done in the XML document
-
(not yet available, working on it as I write this!) the layout generates the XML code for all the boxes (rectangles of data generally at the top, sides, and bottom of the page)
-
on return, the layout process calls generate_page_content() which allows other plugins to tweak the content that the plugin just generated and add yet other parameters to the XML document
-
at this point, the layout checks for filters to be applied on the page (not fully implemented yet) and run those filters against the XML data
-
Now we run the XSLT of the current theme against that data; the output is still XML only the body is now fully formed
-
To finish up the page, the layout calls the apply_theme() function which generates the HTML (at this time we are limited to HTML, later we'll also support Text and PDF and probaly other formats. This will be defined by the XSLT document.)
-
At that point we return all the way up to the snap_child that checks the output buffer, if the buffer is empty, it considered that the page was not found and it generates a 404
-
If the snap_child buffer is not empty, it generates a 200 and outputs the HTML back to the snap.cgi which in turn sends it to Apache which in turn sends it to the client