Zope
  Home arrow Zope arrow Page 3 - Creating Zope Products
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

Creating Zope Products
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 14
    2006-03-07


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

  • 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


    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
     

       

    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 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek