4. PyWork and HTTP

In this section we will explain the lifecycle of an HTTP request processed by PyWork. This hopefully will let you understand how your python code is executed and when.

When an HTTP request enters the Apache server it looks up any associated information loaded from the configuration file and detects that a certain extension (normally .action) has associated a mod_python handler, PyWork. The request is then forwarded to PyWork which looks up the uri in the structures of the loaded configuration file, to resolve which action it must execute. When the action class is found a new instance is created. Then it sets all request parameters (sent via GET or POST) to the action, by first looking up if a writeable property exists on this instance (Attention if an unknown parameter is sent to the object the request fails and no application code is executed). Also in this phase parameter-binded events are looked up and the first one found will be executed , if no events are found then PyWork will used the execute method. Once the method lookup is done it retrieves the HTTP session and then executes the action method. This method must return a proper view identifier or set the redirect uri property. This view identifier is then looked up in the structures to get the proper view information (view handler,file,etc). Then the proper view handler is called with all this information and the action results (for ZPT would be the python object, for XSLT an xml string), the view handler then outputs the proper information to the response directly. For extended information please see the

4.1 Action


See About this document... for information on suggesting changes.