Zope
  Home arrow Zope arrow Page 5 - Form Processing With Zope
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

Form Processing With Zope
By: Team Melonfire, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 11
    2002-02-26


    Table of Contents:
  • Form Processing With Zope
  • Driving Under The Influence
  • Stringing Things Along
  • Running On Empty
  • In The Raw
  • You've Got Mail!
  • Endgame

  • 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


    Form Processing With Zope - In The Raw
    ( Page 5 of 7 )

    In case you want to see what values are being passed back and forth between the Form and FormProcessor, you can simply display the contents of the REQUEST namespace. Take a look at the form processor below for an understanding of what this means:

    <dtml-var standard_html_header> <dtml-var REQUEST> <dtml-var standard_html_footer>
    Now, when you submit a form to this FormProcessor object, you'll see something like this:



    The REQUEST namespace contains a whole bunch of environment and Zope variables that you can use for your own dark purposes. These include, among others, the standard variables HTTP_USER_AGENT, HTTP_REFERER and PATH_INFO, Zope-specific variables like PUBLISHED, SERVER_URL, AUTHENTICATED_USER and URL0, and cookie and session data.

    This ability to access form variables in this manner brings up another interesting item. Thus far, I've been creating individual Form and FormProcessor objects. However, it's also possible to create a combined object, simply by testing for the presence or absence of 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:ignore-empty"> <p> Home planet: <br> <input name="planet:ignore-empty"> <p> Distance (light years) from Earth: <br> <input name="distance:ignore-empty"> <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.

    There are a couple of other things you could do to the form object above. First, you could replace the object name in the form's ACTION attribute

    <form action="DualPurposeForm" method="POST">
    with the special Zope variable "URL0".

    <form action=<dtml-var URL0> method="POST">
    URL0 is a Zope variable which always holds the name of the current URL (you'll see it in the list of variables displayed within the REQUEST namespace). Using this built-in variable covers you in case you need to change the object name in future. You might also want to wrap the "if" test within a namespace localizer - for example, <dtml-with> - in order to ensure that Zope checks the REQUEST namespace for the "submit" variable first, rather than any other namespace that exist.

     
     
    >>> More Zope Articles          >>> More By Team Melonfire, (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 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek