Home arrow Zope arrow Page 2 - The Number Game

Reading The Funnies - Zope

Despite what you might think, it's fairly easy to write MySQL-based Web applications with Zope. In this case study, find out how to do just that by building a Zope-based online poll which uses MySQL to store poll questions and user responses, and DTML Methods to extract and present this information.

TABLE OF CONTENTS:
  1. The Number Game
  2. Reading The Funnies
  3. Start Me Up
  4. Rocking The Vote
  5. Down Memory Lane
  6. Cookie-Cutter Code
  7. Adding It All Up
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 7
April 16, 2002

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
Since I'm going to be using a MySQL database to store the poll's questions and answers, together with user responses, the first task is to design the relevant tables. Here's what I came up with:

# # Table structure for table 'poll' CREATE TABLE poll ( qid int(10) unsigned NOT NULL auto_increment, question varchar(255) NOT NULL, response1 varchar(255) NOT NULL, response2 varchar(255) NOT NULL, response3 varchar(255) NOT NULL, votes1 int(10) unsigned DEFAULT '0' NOT NULL, votes2 int(10) unsigned DEFAULT '0' NOT NULL, votes3 int(10) unsigned DEFAULT '0' NOT NULL, date date DEFAULT '0000-00-00' NOT NULL, PRIMARY KEY (id) ); # # Column descriptions: # # qid - a unique identifier for each poll question # question - the poll question # response1 - possible response #1 # response2 - possible response #2 # response3 - possible response #3 # votes1 - number of votes for response #1 # votes2 - number of votes for response #2 # votes3 - number of votes for response #3 # date - date on which poll was posted #
Just to get things started, I also INSERTed the first question into the database, together with three possible responses.

# # Dumping data for table 'poll'#INSERT INTO poll (qid, question, response1, response2, response3,votes1, votes2, votes3, date) VALUES ( '1', 'The coolest comic strip ofall time is', 'Dilbert', 'Peanuts', 'Calvin and Hobbes', '0', '0', '0','2002-03-07');
At this point, it's also a good idea to verify that your Zope installation supports MySQL via the Z MySQL Database Adapter.

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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

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

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: