Zope
  Home arrow Zope arrow Page 2 - 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 - The Stuffing
    ( Page 2 of 4 )

    The first thing we'll need to do is create an __init__ method. The purpose of this is to accept attributes when an instance of our Product is created. In this example, we'll accept the attributes id, title and nickname:

       ...

       def __init__(self, id, title, nickname):
          "Initialization."
          self.id = id
          self.title = title
          self.nickname = nickname

    We can now add actual content to our Product. The methods that we create will be available as separate pages in our Product. These pages can be accessed by attaching the associated method's name to the id of the Product instance in a request (for example, http://localhost/instance/methodOne). We'll start with index_html, the default page that's called when nothing is specifically requested:

       ...

       def index_html(self):
          "Default page."
          out = '<html><head><title>' + self.title +
    '</title></head><body>'
          out = out + 'Hello, I am ' + self.title + ', but my friends
    call me ' + self.nickname + '.'
          out = out + '</body></html>'
          return out

    In the above method, we return a page that displays the instance's title and the value of the nickname attribute we accepted in the __init__ method earlier. Let's add one more method that lists data about an instance:

       ...

       def list_info(self):
          "A list of information."
          out = '<html><head><title>' + self.title +
    '</title></head><body>'
          out = out + '<b>ID:</b> ' + self.id
          out = out + '<br /><b>Name:</b> ' + self.title
          out = out + '<br /><b>Nickname:</b> ' + self.nickname
          out = out + '</body></html>'
          return out



     
     
    >>> 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