Zope
  Home arrow Zope arrow Page 8 - DTML Basics (part 2)
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
ZOPE

DTML Basics (part 2)
By: Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 4
    2002-06-05


    Table of Contents:
  • DTML Basics (part 2)
  • If Only...
  • Comparing Apples And Oranges
  • Welcome To The Matrix
  • Celluloid Dreams
  • Paring It Down
  • Deeper And Deeper
  • Submitting To The King

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    DTML Basics (part 2) - Submitting To The King
    ( Page 8 of 8 )

    You'll have noticed that in all the examples shown thus far, we've used two Zope objects - a single DTML Document containing the form, and a separate DTML Method which processes the form input and generates appropriate output. However, DTML provides an elegant method to combine those two pages into one via the "submit" variable.

    In order to better understand this, create a new DTML Document named "DualPurposeForm" and add the following DTML code to it:

    <dtml-var standard_html_header>

    <dtml-if submit>

    Welcome to Earth, <b><dtml-var species missing="Alien"></b> from the
    planet <b><dtml-var planet missing="Zorgo"></b>.
    <p>
    How was your journey? Travelling <b><dtml-var distance missing="so
    many"></b> light years must be quite a shock to the system. Why don't
    you relax and have a drink?

    <dtml-else submit>

    <form action="DualPurposeForm" method="POST">
    Species:
    <br>
    <input name="species">
    <p>
    Home planet:
    <br>
    <input name="planet">
    <p>
    Distance (light years) from Earth:
    <br>
    <input name="distance">
    <p>
    <input type="Submit" name="submit" value="Beam Me Up, Scotty"> </form>

    </dtml-if>

    <dtml-var standard_html_footer>
    In this case, the DTML "if" test will first check to see if the "submit" form variable exists. If it does, it implies that the form has been submitted, and the second half of the script, the actual form processor, comes into play. If it doesn't, it implies that the form has not yet been submitted, and so the initial, empty form is displayed.

    This technique makes it possible to reduce the number of objects used, and perhaps make your Zope object collection easier to handle.

    And that's about it for the moment. In this article, you learnt a little more about DTML, specifically about how to introduce decision-making logic into your Methods with DTML's numerous conditional statements. You learnt about the "if" and "unless" series of conditional statements, and saw a few examples of the different variants possible. Finally, you saw how all that theory can be put to practical use by implementing a simple form processor for use on a Web page.

    In the next issue of DTML Basics, I'll be rounding out the fundamentals with a look at the various loop constructs provided by DTML. As with everything you've seen so far, DTML comes with its own twist (pardon the pun) on the traditional way of implementing loops. Come back next time to see what I'm talking about...and, until then, go practise.

    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!

     
     
    >>> More Zope Articles          >>> More By Harish Kamath, (c) Melonfire
     

       

    ZOPE ARTICLES

    - Creating Zope Products
    - Plone Content Types With Archetypes
    - Flat User Management in Zope
    - Creating Basic Zope Applications
    - Getting started with Zope for Linux and Sola...
    - ZPT Basics (part 4)
    - ZPT Basics (part 3)
    - ZPT Basics (part 2)
    - ZPT Basics (part 1)
    - Exception Handling In DTML
    - DTML Basics (part 4)
    - DTML Basics (part 3)
    - DTML Basics (part 2)
    - DTML Basics (part 1)
    - Using Zope With Apache





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek