Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function split() is deprecated in /home3/vvaswani/public_html/community/columns/trog/article.php on line 101

Deprecated: Function eregi_replace() is deprecated in /home3/vvaswani/sql.php on line 301

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home3/vvaswani/public_html/community/columns/trog/article.php on line 107

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home3/vvaswani/public_html/community/columns/trog/article.php on line 109

Deprecated: Function ereg_replace() is deprecated in /home3/vvaswani/public_html/community/columns/trog/article.php on line 124

Deprecated: Function ereg_replace() is deprecated in /home3/vvaswani/public_html/community/columns/trog/article.php on line 125

Deprecated: Function split() is deprecated in /home3/vvaswani/public_html/community/columns/trog/article.php on line 127

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174
The Melonfire Community - Trog
Logo         Community
  Trog
Services
The Company
Community
Columns
Your Account
Contact Us
 
 
DTML Basics (part 4)
Find out how to manipulate the variable namespace and build tree structures in DTML.

| With Or Without You |

We'll begin with something interesting. Create a DTML Document named "WithOrWithoutYou" and insert the following code.


<b>
The value of "id" is <dtml-var id><br>
The value of "icon" is <dtml-var icon><br>
The value of "me" is <dtml-var me>
</b>


Now, call this script with three parameters, like this:


http://localhost:8080/DTML%20Basics/WithOrWithoutYou?id=1234&icon=folder&me=John


In other words, I'm explicitly passing it values for the "id", "icon" and "me" variables. But when I view the output of the script, I see something completely different:


The value of "id" is WithOrWithoutYou
The value of "icon" is misc_/OFSP/dtmldoc.gif
The value of "me" is John


Of the three values passed, only one appeared correctly. How come?

Take a look at the variable names used in the example. While the third one does not ring a bell, the first two are among the default properties associated with each and every Zope object.

Now, if you go back a little, you'll remember a little thing called acquisition, a concept I took great pains to explain - basically, the process by which Zope tries to find a value for a variable. As I said before, Zope will first look for the variable value in the current folder and then traverse upwards to the root folder in search of it. If it is still unsuccessful, it looks in a couple of other places for the missing information; these places include cookies and form data sent using POST or GET methods.

Now, the entire gamut of objects and locations listed above represent a nebulous entity that Zope refers to as the "namespace". By default, Zope places some default objects in this namespace when it starts up. Subsequent objects are added to this "stack" as and when they are invoked.

Consequently, when you load the DTML Document above, it is pushed to the top of the namespace stack along  with its "id" and "icon" properties. When DTML tries to replace the value of the variables "id" and "icon" in the DTML Document, it encounters these two properties at the top of the namespace stack before even getting around to looking in the query string (which are always located at the bottom of the namespace stack). Which explains why the values passed on the query string never show up in the output of the script.

That said, since no value exists for the variable "me" in the namespace stack, Zope will finally get around to looking in the GET query string, locate the variable value and print it.

Obviously, this behaviour isn't always what you want. Which is where the <dtml-with> tag comes in.


How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.

Read more, or grab your copy now!


previous page more like this  print this article  next page
 
Search...
 
In trog...
Logging With PHP
Building A Quick-And-Dirty PHP/MySQL Publishing System
Output Buffering With PHP
Date/Time Processing With PHP
Creating Web Calendars With The PEAR Calendar Class
more...
 
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
more...
 
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
more...
 
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
more...
 
In cut!...
American Chai
The Core
Possession
more...
 
Find out how you can use this article on your own Web site!


Copyright © 1998-
Strict Standards: mktime(): You should be using the time() function instead in /home3/vvaswani/public_html/community/columns/trog/article.php on line 731
2018 Melonfire. All rights reserved
Terms and Conditions | Feedback