Zope
  Home arrow Zope arrow Page 7 - The Number Game
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

The Number Game
By: Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 7
    2002-04-16


    Table of Contents:
  • The Number Game
  • Reading The Funnies
  • Start Me Up
  • Rocking The Vote
  • Down Memory Lane
  • Cookie-Cutter Code
  • Adding It All Up

  • 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


    The Number Game - Adding It All Up
    ( Page 7 of 7 )

    The final item on today's menu is perhaps the simplest - a form which allows administrators to easily add new questions to the system.

    This DTML method, aptly named "addPoll", is divided into two sections, as seen in the listing below:

    <dtml-var standard_html_header> <h3>Add New Poll</h3> <dtml-if submit> <dtml-call insertPoll> <h4>Poll added successfully!</h4> <p> Click here to <a href="viewCurrentPoll">view</a> it. <p> <dtml-else> <table border="0" cellspacing="5" cellpadding="5"> <form action="addPoll" method="post"> <tr> <td>Poll question<br><input type="Text" name="question" size="25"></td> </tr> <tr> <td>Response 1<br><input type="Text" name="response1" size="25"></td> </tr> <tr> <td>Response 2<br><input type="Text" name="response2" size="25"></td> </tr> <tr> <td>Response 3<br><input type="Text" name="response3" size="25"></td> </tr> <tr> <td align=center><input type=submit name=submit value="Add Poll"></td> </tr> </form> </table> </dtml-if> <dtml-var standard_html_footer>
    The first task is to check if the form has been submitted. If it has not yet been submitted, then the method generates an empty form, with fields for the question and possible responses. Once the form is submitted, the data entered into the form by the administrator is inserted into the database via the "insertPoll" Z SQL Method below.

    INSERT INTO poll (question, response1, response2, response3, date) VALUES ( <dtml-sqlvar question type="string">, <dtml-sqlvar response1 type="string">, <dtml-sqlvar response2 type="string">, <dtml-sqlvar response3 type="string">, <dtml-sqlvar ZopeTime type="string">)
    Note that the built-in ZopeTime DTML variable (which returns the current system time) has been used to insert the current date as part of the table record. This is similar to the now() function that is built into the MySQL database.

    Here's what the form and its result look like:





    And that's about it. Hopefully, this exercise gave you some insight into how Zope can be used to build a simple Web application, and illustrated its power and flexibility as a rapid development tool for the Web medium. See ya! Note: All examples in this article have been tested on Linux/i586 with Zope 2.5. 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