|
Size: 2070
Comment:
|
← Revision 5 as of 2011-02-10 15:02:35 ⇥
Size: 2058
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 10: | Line 10: |
| * AbortScript: script that gets run if abort_page is called by the content generator or by AfterScript. |
* AbortScript: script that gets run if abort_page is called by the content generator or by AfterScript. |
| Line 13: | Line 12: |
| * ForceAfterScript (or FinalAfterScript or whatever): it's run anyway regardless the completion code of the script that ran before in the request process |
* ForceAfterScript (or FinalAfterScript or whatever): it's run anyway regardless the completion code of the script that ran before in the request process |
| Line 17: | Line 14: |
| * Command abort_page will have an internal status flag 'aborting' to be set in the module globals. This flag is set to 0 at the very beginning of the request processing (Rivet_SendContent). 'abort_page' tests this flag, if 0 it gets set as 1 and the command returns TCL_ERROR setting the usual error info that are trapped in Rivet_ExecuteAndCheck. |
* Command abort_page will have an internal status flag 'aborting' to be set in the module globals. This flag is set to 0 at the very beginning of the request processing (Rivet_SendContent). 'abort_page' tests this flag, if 0 it gets set as 1 and the command returns TCL_ERROR setting the usual error info that are trapped in Rivet_ExecuteAndCheck. |
| Line 27: | Line 20: |
| * 'abort_page' will accept an argument to be later retrived with a new command 'abort_condition'. AbortScript may check this condition variable to branch into different blocks of code. |
* 'abort_page' will accept an argument to be later retrived with a new command 'abort_condition'. AbortScript may check this condition variable to branch into different blocks of code. |
| Line 38: | Line 29: |
| should test the definition of a new conf variable rivet_abort_script and execute it if defined. The whole function has to also check for the new conf variable rivet_force_script and run it anyway before printing the headers and flushing the channel. |
should test the definition of a new conf variable rivet_abort_script and execute it if defined. The whole function has to also check for the new conf variable rivet_force_script and run it anyway before printing the headers and flushing the channel. |
Exception Handling
The definition exception handling could be misleading. This is a mechanism based on the command abort_page, rather than a language specific exception handling as it's done in tcl8.6 or through the 'catch' core command.
abort_page terminates a script and returns control to the module core with a special return code. The module checks the error code and skips subsequent scripts (AfterScript) printing an error message and dropping already sent page contents from the output channel.
this is a proposal for a new handling of this mechanism that hopefully should preserve existing code maintaining full compatibility:
AbortScript: script that gets run if abort_page is called by the content generator or by AfterScript.
ForceAfterScript (or FinalAfterScript or whatever): it's run anyway regardless the completion code of the script that ran before in the request process
Command abort_page will have an internal status flag 'aborting' to be set in the module globals. This flag is set to 0 at the very beginning of the request processing (Rivet_SendContent). 'abort_page' tests this flag, if 0 it gets set as 1 and the command returns TCL_ERROR setting the usual error info that are trapped in Rivet_ExecuteAndCheck.
Any subsequent call to the command will return TCL_OK disabling its effects within ForceAfterScript (just making sure that it cannot be interrupted in this way).
'abort_page' will accept an argument to be later retrived with a new command 'abort_condition'. AbortScript may check this condition variable to branch into different blocks of code.
Basically, the code in Rivet_ExecuteAndCheck where the abort condition is checked
if (strcmp (Tcl_GetString (errorCodeElementObj), "RIVET") == 0) {
- ..
}
should test the definition of a new conf variable rivet_abort_script and execute it if defined. The whole function has to also check for the new conf variable rivet_force_script and run it anyway before printing the headers and flushing the channel.