Zope
  Home arrow Zope arrow Page 3 - Creating Zope Products
FaxWave - Free Trial.
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 
 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

Creating Zope Products
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 13
    2006-03-07

    Table of Contents:
  • Creating Zope Products
  • The Stuffing
  • Inner Mechanisms
  • Finishing Touches

  • 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

    Route your faxes to your email inbox. Private, secure fax numbers available from CallWave. Choose your fax number.

    Creating Zope Products - Inner Mechanisms
    (Page 3 of 4 )

    Now that we've described our Product by building a class, we'll have to work on a few inner mechanisms required to actually use our Product. The first two mechanisms we add to our Product will be responsible for creating instances of that Product. The first one will accept information about the instance to be created, such as the id, title and nickname attributes we make define in __init__. This data will then be passed to the second mechanism. This second mechanism will be responsible for actually adding the instance to Zope based on the data we entered into the first mechanism.

    All that's needed for the first mechanism is a simple form that requests the data we use in __init__. Note that this is not included in our Product class, but it does go into the same file.

    ...

    def addForm(self):
       "Accept basic information about the instance."
       out = '<html><head><title>Person Product</title></head><body>'
       out = out + '<form action="addProduct">'
       out = out + '<b>ID:</b> <input type="text" name="id" /><br />'
       out = out + '<b>Name:</b> <input type="text"
    name="title" /><br />'
       out = out + '<b>Nickname:</b> <input type="text"
    name="nickname" /><br />'
       out = out + '<input type="submit"></form></body></html>'
       return out

    As I said above, the addForm method is simply a form that accepts the information we will use to create our instance, id, title and nickname. Once we have this information, we can then use the information to actually create an instance of our Product. To do this, we use the _setObject method:

    def addProduct(self, id, title, nickname):
       "Add an instance."
       self._setObject(id, Person(id, title, nickname))
       return "Object created."

    We pass the _setObject method two arguments. The first is the id of our instance, and the second is an actual instance of our Person class, to which we pass the information obtained in addForm. Finally, we return a message stating that our object has been created.

    More Zope Articles
    More By Peyton McCullough


       · Hey, all,This article focuses on creating Zope products. In my experience, they...
       · Hi,I think you should also mention the security definitions. They are really a...
     

       

    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-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway