Zope
  Home arrow Zope arrow Page 3 - Form Processing With Zope
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Developerworks
 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? 
ZOPE

Form Processing With Zope
By: Team Melonfire, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 10
    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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    PCmover - $15 Off with Coupon Code CJPH7Q

    Form Processing With Zope - Stringing Things Along
    (Page 3 of 7 )

    Obviously, there's a lot more you can do with Zope than just this. One of the coolest things has to be the ability to enforce data types and checks on the data entered into a form. If you've ever had to code a form processor, this capability is sure to save you a couple of hours of work.

    Let's see how it works, by modifying the Form object created previously:

    <dtml-var standard_html_header> <form action="FormProcessor" method="POST"> Species: <br> <input name="species:string"> <p> Home planet: <br> <input name="planet:string"> <p> Distance (light years) from Earth: <br> <input name="distance:int"> <p> <input type="Submit" value="Beam Me Up, Scotty"> </form> <dtml-var standard_html_footer>
    In this case, I've specified that the first two fields must contain string values, while the third must contain an integer. Assuming, for example, that the user enters a string instead of an integer into the last field, Zope will halt form processing and display an error message. Here's what it looks like:



    A little scary, but nevertheless effective in communicating the error. Obviously, you can customize this page to your own requirements.

    A number of types can be enforced on form variables - here's a quick list:

    "float" - a floating-point number;

    "int" - an integer;

    "long" - a long integer;

    "string" -a character string;

    "text" - a line-separated string;

    "lines" - a list of values separated by lines;

    "date" - a date/time value

    You can enforce that a field typed as "string" be non-empty by using the "required" value in it. For example, the following code modifies the Form object above to require information on the home planet:

    <dtml-var standard_html_header> <form action="FormProcessor" method="POST"> Species: <br> <input name="species:string"> <p> Home planet: <br> <input name="planet:required"> <p> Distance (light years) from Earth: <br> <input name="distance:int"> <p> <input type="Submit" value="Beam Me Up, Scotty"> </form> <dtml-var standard_html_footer>

    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

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway