|
|||||||
1. Introduction
2. Installing Karrigell 3. The Web server 4. Working with Apache or Xitami 5. Programming 6. Debugging 7. Python scripts 8. Karrigell Services 9. Python Inside HTML 10. HTML Inside Python 11. HTMLTags - generate HTML in Python 12. Including documents 12.1 Namespace 12.2 Passing parameters 13. Sessions 14. Authentication 15. Internationalization |
12. Including other documents or scriptsInside a script you can ask Karrigell to include the content of another static file or the output of another script by theInclude(url)
function, where url is the url of the file or script
(you can use aliases as for ordinary files)
This is useful if you want to build a set of pages with components which will be present in each page (for instance a header and/or a footer). Your script will be built this way :
At runtime, Karrigell will raise a RecursionError in case of loops (scripts that include themselves, or script 1 includes script 2 which includes script 1) 12.1 NamespaceAn included script is run in the same namespace as the script which "calls" it, including the variables defined in this script : if the caller script is
and whoseName.py is
you'll see that the 12.2 Passing parametersIt can be useful to pass parameters to an included script : see for instance the menu script in the personal portal demo. This script takes as parameters a list of menu items and the list of matching urlsIt will be included this way :
Parameters can also be passed in the query string appended to the script
url : with |