You'll remember that I told you, a while back, that every TALES path expression must begin with a variable name. The TALES specification defines a number of such variables - here's a list of the most important ones: "nothing" - a null value "repeat" - a built-in TALES variable used for repetition "root" - the starting point for the object hierarchy "here" - the current context "template" - the template itself "container" - the template's container "request" - the request object You've already seen the "template" context in action - now let's take a look at the "request" context, which contains information about the current HTTP request. Consider the following example, which, when rendered, displays the current URL: This context also comes in handy when you're building Web forms and need to access the values of the various form variables. Consider the following simple DTML Document: This displays the following form to the user. ![]() Next, create the form processing script, "formHandler", using a Page Template: Try it out - here's an example of what you might see: ![]() The beauty of this example lies in its simplicity. I've used the "request" context and obtained access to the form variables simply by specifying the appropriate path - the "request/form/name" path for the form variable "name", and the "request/form/filling" path for the form variable "filling". And that's about it for this first part of the series. In this article, I gave you a gentle introduction to the ZPT way of doing things, explaining the special "content" and "replace" TAL attributes. In the next segment, I'll be looking at a few more of TAL's special attributes, including the ones that let you define variables and write conditional statements. Make sure you tune in for that one...and until then, stay healthy! Note: All examples in this article have been tested on Linux/i586 with Zope 2.5.0. Examples are illustrative only, and are not meant for a production environment. Melonfire provides no warranties or support for the source code described in this article. YMMV!
blog comments powered by Disqus |